Hi, I want to create a for loop to go through each of the pages (20) of a matrix 400x600x20 (called polygons). The matrices 400×600 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 400×600 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
Best Answer