Access values in cell array in each loop.

1 次查看(过去 30 天)
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by