Access values in cell array in each loop.

1 visualización (últimos 30 días)
Anh Nguyen
Anh Nguyen el 2 de Oct. de 2023
Comentada: Voss el 2 de Oct. de 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

Respuesta aceptada

Voss
Voss el 2 de Oct. de 2023
Editada: Voss el 2 de Oct. de 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 comentarios
Anh Nguyen
Anh Nguyen el 2 de Oct. de 2023
Movida: Voss el 2 de Oct. de 2023
That's great! Thank you.
Voss
Voss el 2 de Oct. de 2023
You're welcome!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by