How to loop over this lines?
조회 수: 1 (최근 30일)
이전 댓글 표시
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;
댓글 수: 0
채택된 답변
Rik
2019년 2월 6일
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
Rik
2019년 2월 6일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!