How to save variable in loop with different name?

2 visualizzazioni (ultimi 30 giorni)
i want to save each loop resust in varible of drought.
drougths=['june1965','june1969','june1974', 'july1987', 'july2002', 'july2006','aug1968', 'aug1979', 'aug1987', 'sep1952', 'sep1987','sep2001'];
j=1;
for i=[174, 222, 282,439,619,667, 212, 344, 440, 21, 441,609]
b(:,:)=IMD_SPI_01_12(i,:,:);
c=reshape(b,129,135);
for k=j
droughts(j)=c;
end
j=j+1;
end

Risposte (1)

Walter Roberson
Walter Roberson il 21 Set 2019
  1 Commento
Walter Roberson
Walter Roberson il 21 Set 2019
By the way, you should be using
drougths={'june1965','june1969','june1974', 'july1987', 'july2002', 'july2006','aug1968', 'aug1979', 'aug1987', 'sep1952', 'sep1987','sep2001'};
Or if you have R2017a or later you can use your original line, but change every ' to " such as "june1965", "june1969"

Accedi per commentare.

Categorie

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

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by