How to access a table column using a string of the column name
조회 수: 203 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2017년 11월 16일
답변: MathWorks Support Team
2017년 12월 20일
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'?
채택된 답변
MathWorks Support Team
2017년 11월 16일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!