call a variable in a timetable from a cell matrix

1 回表示 (過去 30 日間)
Xymbu
Xymbu 2022 年 1 月 14 日
コメント済み: Xymbu 2022 年 1 月 14 日
I have a loop with the column/variable names of a timetable need to be called in a loop
for 1 = 1:10
a(:,i) = Timetable.VariableNamesMatrix{i}
end
I bolded the part im having an issue with. How can I call a string from a cell array and use it in this fashion so that for example
VariableNamesMatrix{1} = Var1
and the code would enact the part in the loop as Tiimetable.Var1 when i = 1;

採用された回答

Walter Roberson
Walter Roberson 2022 年 1 月 14 日
編集済み: Walter Roberson 2022 年 1 月 14 日
for 1 = 1:10
a(:,i) = Timetable.(VariableNamesMatrix{i});
end
But you should consider just using
a = table2array(Timetable, VariableNamesMatrix);
  1 件のコメント
Xymbu
Xymbu 2022 年 1 月 14 日
Thanks! for both answers def solved this issue. I will use the table2array(). I appreciate the quick response!

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by