Looping through a 3D matrix
조회 수: 7 (최근 30일)
이전 댓글 표시
Hi,
I have this code below but I need to make one column for each from 1 to 39 by vertically catenating. The last two lines as an example shows how I did by manually calling the numbers from 1. But how can i do this in a loop.? Can anyone help me?
Jan_Daily: 31 x 10000 x 39 matrix.
StartROW=1;
EndROW=31;
for i=1:39
St_matrix(:,:,i)=eval(['ZONAL_SEleven' num2str(i)]);
end
for jj=1:39
Jan_Daily(:,:,jj)=St_matrix(StartROW:EndROW,:,jj);
end
All_St1=Jan_Daily(:,:,1);
All_Jan_1=Jan_Daily(:);
댓글 수: 0
답변 (1개)
Narfi
2014년 6월 4일
Damith,
By including the indices in the variable names, you end up with a lot of places where you need to build up strings for evaluation and then call eval.
Have you reconsidered your need about why you need to have 39 different variables as is the recommended way of avoiding calling eval: http://www.mathworks.com/help/matlab/matlab_prog/string-evaluation.html
Best,
Narfi
댓글 수: 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!