Question

I am trying to get a empty 10*10 grid cell in order to fill it up with some outputs afterwards. The code I wrote is:

patch(1:100)=1:100;
mapmatrix= zeros(100,100);
for patchi=1:100,
 for cellxi=1:10,
  for cellyi=1:10,
   mapmatrix(mod(patchi-1,10)*10+cellxi,ceil(patchi/10)*10+cellyi)=patch(patchi);
,end,end,end;

imagesc(mapmatrix)

Does anyone know why I am getting a 10*11 grid cell instead of 10*10?

THX

Was it helpful?

Solution

Obviously, that is because you use different index computing methods for cow and column indexes

mod(patchi-1,10)*10+cellxi

vs

ceil(patchi/10)*10+cellyi
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top