How to save variable in loop with different name?
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Walter Roberson
on 21 Sep 2019
1 Comment
Walter Roberson
on 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"
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!