Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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?

Risposta accettata

Guillaume
Guillaume il 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

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