Select a cell table

4 ビュー (過去 30 日間)
Jonathan Schipper
Jonathan Schipper 2021 年 10 月 21 日
編集済み: Jonathan Schipper 2021 年 10 月 25 日
I have multiple 3x10 tables in my workspace. I want to make a loop that will select a cell, location (2,2) for instance, of the table and save the value of this cell for each of the tables. The tables are called RESP0***_SOZ_TABLE. The '***' are combination of three numbers, like 234, 198, 488.
Numbers is a matrix of the different combinations of numbers, present in my workspace.
Can somebody help me? I have a code that will give '***'_TABLE{2,2}' as a answer, but it doesn't run the code, which is unfortunately because I am interessted in value of (2,2) of 234_TABLE.
for i=1:length(numbers);
j=numbers(i);
value{i} = sprintf('%d_TABLE{2,2}',j);
end

採用された回答

Duncan Po
Duncan Po 2021 年 10 月 22 日
If you want the value in RESP0234_SOZ_TABLE{2,2}, use eval to evaluate that expression:
for i=1:length(numbers);
j=numbers(i);
value{i} = eval(sprintf('RESP0%d_SOZ_TABLE{2,2}',j));
end
  1 件のコメント
Jonathan Schipper
Jonathan Schipper 2021 年 10 月 22 日
Unbelievable, thank you so much! My code just got 1060 lines shorter!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by