Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
Ivan Shorokhov
Ivan Shorokhov am 12 Feb. 2015
Kommentiert: Ivan Shorokhov am 13 Feb. 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?

Akzeptierte Antwort

Guillaume
Guillaume am 12 Feb. 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

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by