Hello; l set an initial value of a vector to [] neighbour_n= [];but once inside the loop neighbour_n(k)= [neighbour_n(k) j] doesnt work it returns me this message the variable n(i) appears to change size in every loop iteration within the script consider prellocating for speed My target is to get a vector of indices [1 3 5 6 ..] returned error : %
??? Attempted to access neighbour_n(1); index out of bounds because numel(neighbour_n)=0.Error in ==> agawa at 52 neighbour_n(k)= [neighbour_n(k) j];%
my code: %
N=200;*neighbour_n(k)= [];*m=0;for k=1:N; for j= k+1 : N; d =((nodesX(k)-nodesX(j))^2+(nodesY(k)-nodesY(j))^2)^0.5; if d<=200; m=m+1; % number of created links
line([nodesX(k),nodesX(j)],[nodesY(k),nodesY(j)]); A(k, j)=1; neighbour_n(k)= [neighbour_n(k) j]; else A(k, j)=0; end; end; display(A(k, j)); end;%
Best Answer