How to loop over this lines?

2 visualizzazioni (ultimi 30 giorni)
Lilya
Lilya il 6 Feb 2019
Commentato: Lilya il 6 Feb 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;

Risposta accettata

Rik
Rik il 6 Feb 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 Commenti
Rik
Rik il 6 Feb 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 il 6 Feb 2019
Thank you so much!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by