Access values in cell array in each loop.

1 回表示 (過去 30 日間)
Anh Nguyen
Anh Nguyen 2023 年 10 月 2 日
コメント済み: Voss 2023 年 10 月 2 日
hi, I have an cell array (60 cells) as shown in the figure and file attached. In each cell, there are two rows. In each row, there are two columns which include date and a number.
Now I want to loop through the cell array to extract number in each row (fB) to input to other model. This means the iteration 1 will have 60 values of the first row, and Iteration 2 will have 60 values of second row.
Could you please show me how to do this?
Thank you.
1

採用された回答

Voss
Voss 2023 年 10 月 2 日
編集済み: Voss 2023 年 10 月 2 日
load array_TT_cell
for iter = [1 2]
fB = cellfun(@(x)x.fB(iter),array_TT);
disp(sprintf('Iteration %d:\n',iter));
disp(fB);
end
Iteration 1:
0 0.0006 0.0006 0.0006 0.0006 0.0006 0.0394 0.0881 0.0117 0.0006 0 0.0006 0.0006 0.0006 0.0006 0.0006 0.5208 1.0000 0.0858 0.0006 0 0.0006 0.0006 0.0006 0.0006 0.0006 0.5208 1.0000 0.0858 0.0006 0 0.0006 0.0006 0.0006 0.0006 0.0006 0.5208 1.0000 0.0858 0.0006 0 0.0006 0.0006 0.0006 0.0006 0.0006 0.4823 0.9147 0.0745 0.0006 0 0.0006 0.0006 0.0006 0.0006 0.0006 0.0006 0.0006 0.0006 0.0006
Iteration 2:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.4867 0.7771 0.0047 0 0 0 0 0 0 0 0.6963 0.9881 0.0047 0 0 0 0 0 0 0 0.6963 0.9881 0.0047 0 0 0 0 0 0 0 0.6963 0.9881 0.0047 0 0 0 0 0 0 0 0.2143 0.2177 0 0
  2 件のコメント
Anh Nguyen
Anh Nguyen 2023 年 10 月 2 日
移動済み: Voss 2023 年 10 月 2 日
That's great! Thank you.
Voss
Voss 2023 年 10 月 2 日
You're welcome!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by