How to save variable in loop with different name?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Antworten (1)
Walter Roberson
am 21 Sep. 2019
1 Kommentar
Walter Roberson
am 21 Sep. 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"
Siehe auch
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!