如何修复"Index in position 1 exceeds array bounds"


 x = gallery('uniformdata',[1,10],0);
 y = gallery('uniformdata',[1,10],1);
 [v,c] = voronoin([x(:) y(:)]); %returns an array V with vertices and a cell array C with a matrix for each cell of the diagram. 
 v = v( ~any( isnan( v ) | isinf( v ), 2 ),: );
 for ii=1:numel(c)
        v(c{ii},:) %contains the vertices to cell number ii, corresponding to centroid x,y(ii,:).     
 end

v(c{1},:)似乎执行正常,但是一旦达到v(c{2},:),我会得到此错误

"位置1中的索引超过数组范围(不得超过13(。"

注意:numel(v)返回13

我尝试了for ii=1:numel(c)-1,但这似乎不起作用

v = v(...)更改数组vc中的索引不再匹配数组v

您应该删除那条代码。

最新更新