How to access a table column using a string of the column name
248 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 16 Nov. 2017
Beantwortet: MathWorks Support Team
am 20 Dez. 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'?
Akzeptierte Antwort
MathWorks Support Team
am 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Cell Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!