Access values in cell array in each loop.

1 view (last 30 days)
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

Accepted Answer

Voss
Voss on 2 Oct 2023
Edited: Voss on 2 Oct 2023
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

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!