Borrar filtros
Borrar filtros

How to store <500x500> double in a loop?

1 visualización (últimos 30 días)
Ivan Shorokhov
Ivan Shorokhov el 12 de Feb. de 2015
Comentada: Ivan Shorokhov el 13 de Feb. de 2015
I have following loop,
for e=1:25
:
:
:
finalLSF(e)=phi; % phi is where 500x500 double
end
How to store 500x500 double in a loop I have tried finalLSF(e) and finalLSF{e}, but it gives me an errors:
In an assignment A(I) = B, the number of elements in B and I must be the same.
and
Cell contents assignment to a non-cell array object.
How it is can be done properly in matlab?

Respuesta aceptada

Guillaume
Guillaume el 12 de Feb. de 2015
finalSF{e} should work. If you're getting an error, it's probably because finalSF already exists before the loop as something else than a cell array. To fix that:
finalSF = cell(1, 25); %before the loop.
Another option is to declare finalSF as a 3d array, since all your phi are the same size:
finalSF = zeros(500, 500, 25);
for idx = 1:25
%calculate phi
finalSF(:, :, e) = phi;
end
  1 comentario
Ivan Shorokhov
Ivan Shorokhov el 13 de Feb. de 2015
@Guillaume, thank you for such open answer!

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.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by