How to access a table column using a string of the column name
29 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 16 Nov 2017
Réponse apportée : MathWorks Support Team
le 20 Déc 2017
If you have a table called table1 with column names X1, X2, X3, how can you access a column X1 with the variable v = 'X1'?
Réponse acceptée
MathWorks Support Team
le 16 Nov 2017
This can be done using dynamic field indexing.
>> table1.('X1');
If you have a variable that contains the string.
>> v = 'X1';
>> table1.(v);
Note: This indexing also works for dataset arrays and structs.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Tables dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!