Using strc to make elements for calling a table column does not work

1 回表示 (過去 30 日間)
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2019 年 12 月 27 日
コメント済み: Walter Roberson 2019 年 12 月 29 日
I need to call some columns of a table in automated way. The name pof table is T and I use this line to make the T.table_column:
variable_names=strcat('T.',var(i));
and the output of this code is:
variable_names =
1×1 cell array
{'T.i_nPix'}
I need to call T.i_nPix in which T is table name and i_nPix is table column. But this format {'T.i_nPix'} which is cell array and string is not able to be recognized as table.table_column. How can I solve the issue?

採用された回答

Walter Roberson
Walter Roberson 2019 年 12 月 27 日
T.(var{i})
  4 件のコメント
Stephen23
Stephen23 2019 年 12 月 28 日
"Do you mean I should change the code lik this? strcat('T.(',var(i),')')"
No, that would be entirely the wrong way to go about this. Much simpler and more efficient to follow Walter Roberson's advice... which is the same as the MATLAB documentation:
Walter Roberson
Walter Roberson 2019 年 12 月 29 日
You can also use
T{:,var{i}}

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by