# How to loop over this lines?

1 view (last 30 days)
Lilya on 6 Feb 2019
Commented: Lilya on 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;

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