How to extract a data from a table using a string stored in a variable

I have a table T with a column called 'Rules_updated'. The extraction is as simple as write
T.Rules_updated
However, in other cases the column could be called 'RulesUpdated'.
I want to save the name as a variable and use the new variable to extract the data from the column. For example:
RulesUpdatedColumn='Rules_updated';
RulesUpdated=T.RulesUpdatedColumn;

 채택된 답변

See the Access Data in Tables page.
a = (1:5)';
A = table(a)
A = 5×1 table
a _ 1 2 3 4 5
varname = "a";
A.(varname)
ans = 5×1
1 2 3 4 5

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

제품

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by