Access values in cell array in each loop.

1 visualizzazione (ultimi 30 giorni)
Anh Nguyen
Anh Nguyen il 2 Ott 2023
Commentato: Voss il 2 Ott 2023
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

Risposta accettata

Voss
Voss il 2 Ott 2023
Modificato: Voss il 2 Ott 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
  2 Commenti
Anh Nguyen
Anh Nguyen il 2 Ott 2023
Spostato: Voss il 2 Ott 2023
That's great! Thank you.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by