How to loop over this lines?

1 vue (au cours des 30 derniers jours)
Lilya
Lilya le 6 Fév 2019
Commenté : Lilya le 6 Fév 2019
Hi all,
could anyone help to creat a loop over the folloing lines?
Thanks a lot for the help.
SW_NRS = nan(11,8,960);
SW = SWGNTWTR{1,1}(NRS_lat,NRS_lon,1:24);
SW_NRS (1:11,1:8,1:24)= SW;
SW = SWGNTWTR{2,1}(NRS_lat,NRS_lon,1:24);
SW_NRS (1:11,1:8,25:48)= SW;
SW = SWGNTWTR{3,1}(NRS_lat,NRS_lon,1:24);
SW_NRS (1:11,1:8,49:72)= SW;
SW = SWGNTWTR{4,1}(NRS_lat,NRS_lon,1:24);
SW_NRS (1:11,1:8,73:96)= SW;
SW = SWGNTWTR{5,1}(NRS_lat,NRS_lon,1:24);
SW_NRS (1:11,1:8,97:120)= SW;
SW = SWGNTWTR{6,1}(NRS_lat,NRS_lon,1:24);
SW_NRS (1:11,1:8,121:144)= SW;
SW = SWGNTWTR{7,1}(NRS_lat,NRS_lon,1:24);
SW_NRS (1:11,1:8,145:168)= SW;
SW = SWGNTWTR{8,1}(NRS_lat,NRS_lon,1:24);
SW_NRS (1:11,1:8,169:192)= SW;
SW = SWGNTWTR{9,1}(NRS_lat,NRS_lon,1:24);
SW_NRS (1:11,1:8,193:216)= SW;
SW = SWGNTWTR{10,1}(NRS_lat,NRS_lon,1:24);
SW_NRS (1:11,1:8,217:240)= SW;

Réponse acceptée

Rik
Rik le 6 Fév 2019
You mean like this?
SW_NRS = nan(11,8,960);
for k=1:(size(SW_NRS,3)/24)
SW = SWGNTWTR{1,k}(NRS_lat,NRS_lon,1:24);
SW_NRS (1:11,1:8,(1:24)+24*(k-1))= SW;
end
  3 commentaires
Rik
Rik le 6 Fév 2019
I see what went wrong: I wrote {1,k} instead of {k,1}. If you switch those around you should get what you need.
SW_NRS = nan(11,8,960);
for k=1:(size(SW_NRS,3)/24)
SW = SWGNTWTR{k,1}(NRS_lat,NRS_lon,1:24);
SW_NRS (1:11,1:8,(1:24)+24*(k-1))= SW;
end
Lilya
Lilya le 6 Fév 2019
Thank you so much!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by