Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在matlab中创建10*10网格单元_Matlab_Grid - Fatal编程技术网

在matlab中创建10*10网格单元

在matlab中创建10*10网格单元,matlab,grid,Matlab,Grid,我试图得到一个空的10*10网格单元,以便在之后用一些输出填充它。我写的代码是: 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(ma

我试图得到一个空的10*10网格单元,以便在之后用一些输出填充它。我写的代码是:

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)
有人知道为什么我得到的是10*11网格单元而不是10*10吗


显然,这是因为对cow和列索引使用不同的索引计算方法

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

imagesc(mapmatrix==0)
-你知道你的问题是什么吗?确实是@nkjt,mapmatrix(mod(patchi-1,10)*10+cellxi,ceil(patchi/10)*9+cellyi)=patchi(patchi);
ceil(patchi/10)*10+cellyi