MATLAB: Error in Voronoin – (Error using cgprechecks (line 40) Not enough unique points specified.)

cgprechecksgenerated arrayMATLABvoronoivoronoi diagramvoronoi neighborsvoronoin

I'm trying to use voronoin() as part of a larger function to determine the nearest neighbors of experimental points within a system. I made an ideal system of points to test it and the output, using:
clear all
k=1;
while k<=400 %this is the value of n*i and the total number of points in the system
for n = 1:20
for i = 1:20
a(:,k) = [8*rand*n;8*rand*i]; %randomness is to introduce uneven spacing, but removing rand changes nothing
k = k+1;
end
end
end
w=voronoin(a);
However, I consistently get the error message:
Error using cgprechecks (line 40)
Not enough unique points specified.
Error in voronoin (line 58)
cgprechecks(x, nargin, cg_opt);
This is consistent regardless of how many points I generate (have tested for up to k = 40000).
Could someone explain why this error occurs? Is voronoin() unable to process systems with somewhat square symmetry? Thanks!

Best Answer

I had to use a' as the argument instead to fix this, since voronoin only take an m x n matrix as the argument, where m>=n+1.
Related Question