double loop formation question
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello,
I have a doubt about the possibility of forming another loop of following repetation (the size of GWdepth is 74*100*1566, 74 and 100 indicate the lon and lat):
j = 1
for i = 1:30
depth_week_j(:,:,i) = GWdepth(:,:,j);
j = j + 52
end
mean_depth_week_j(:,:,1) = nanmean(depth_week_j,3);
j = 2
for i = 1:30
depth_week_j(:,:,i) = GWdepth(:,:,j);
j = j + 52
end
mean_depth_week_j(:,:,2) = nanmean(depth_week_j,3);
...... I need to repeat this process for 52 times until j = 52,
j = 52
for i = 1:30
depth_week_j(:,:,i) = GWdepth(:,:,j);
j = j + 52
end
mean_depth_week_j(:,:,52) = nanmean(depth_week_j,3);
Any ideas on how to form a double loop based on this condition?
댓글 수: 0
채택된 답변
David Hill
2020년 4월 3일
for j=1:52
jj=j;
for i = 1:30
depth_week_j(:,:,i) = GWdepth(:,:,jj);
jj = jj + 52;
end
mean_depth_week_j(:,:,j) = nanmean(depth_week_j,3);
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!