Accesing data in a three dimensional matrix using a for loop
이전 댓글 표시
Hi, I want to create a for loop to go through each of the pages (20) of a matrix 400x600x20 (called polygons). The matrices 400x600 are binary matrices with ones(1) and zeros(0), with different polygons in each of the 20 pages. I have an original matrix (called main01) of 400x600 from where I want to use the data to copy the ones(1) and zeros(0) and locate it in the polygons in each of the 20 pages of the other variable. So I try this creating a variable of only the first page of the matrix polygons:
polygon1(polygon1==1)=main01(polygon1==1);
And it works very well. However, when I set this into a for loop it doesn't give me the zeros and ones of the main01 matrix, it just return the same matrix as polygons.
count=20;
for u=1:1:count;
if polygons(:,:,u)==1
polygons=main01(polygons(:,:,u)==1;
end
end
I will appreciate some help with this for loop.
Thank you. Martha
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!