How to save variable in loop with different name?

1 visualización (últimos 30 días)
Prakhar Deroliya
Prakhar Deroliya el 21 de Sept. de 2019
Comentada: Walter Roberson el 21 de Sept. de 2019
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

Respuestas (1)

Walter Roberson
Walter Roberson el 21 de Sept. de 2019
  1 comentario
Walter Roberson
Walter Roberson el 21 de Sept. de 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"

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by