How I can to rename a variable in loop for?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
t= length(tiempo);
o= 1;
mes{'enero','febrero','marzo','abril','mayo','junio','julio','agosto','septiembre','octubre','noviembre','diciembre'};
for j = 1:12:t;
J = moist_end(:,:,1,j);
strcat('moist_',mes(o))(:,:,:,o) = J
o=o+1;
end
2 Kommentare
Antworten (2)
Matt J
am 12 Aug. 2014
Not sure what you're trying to do, but if you want to split J into differently named partitions, the appropriate way would be to use a structure,
for j = 1:12:t;
J = moist_end(:,:,1,j);
moistStruct.(mes{o}) = J
o=o+1;
end
0 Kommentare
Ahmet Cecen
am 12 Aug. 2014
Bearbeitet: Ahmet Cecen
am 12 Aug. 2014
There is an ugly way to do this using the eval function. Something like:
for i=1:12:t
eval(strcat('moist_',mes(o),'(:,:,:,',num2str(o),')','=J'));
end
0 Kommentare
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!