Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Griddata: Not enough sample points specified
Date: Mon, 29 Oct 2012 15:26:08 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 44
Message-ID: <k6m76g$414$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-00-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1351524368 4132 172.30.248.45 (29 Oct 2012 15:26:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 29 Oct 2012 15:26:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 3811876
Xref: news.mathworks.com comp.soft-sys.matlab:781585

I'm quite new to MatLab and really am only using it for a tiny bit of my thesis. I am trying to interpolate 3D values (x,y,z) to make a 3D model of a fossil. I have a set of code that SHOULD work, but it tells me that the griddata doesn't have enough sample points specified. Does anyone know how to fix this or can anyone tell me where to direct my attention to? 
This line of code also has an error in it: Z = griddata(zpts(:,1),zpts(:,2),zpts(:,3),X,Y);  
and I have no clue as to why. 
Here is all of the code: (there are notes at the ends of the lines <green matlab  text> 
function Crinoid(data)
%Crinoid - routine to interpolate 3-D values for a crinoid specimen
%  Functionalized for convenience
%  Call syntax :  Crinoid(data)

%Copy the data so the original is preserved - not really necessary if run
%as a function (because all aviarbles are local
data='BackGS5Data.csv';
centroids=data;
%Find all the points where there is z data
zpts=data(data(:,3)>0,:);
%zpts=data;

%Find the x,y extent of the data
minx=min(centroids(:,1));
maxx=max(centroids(:,1));
miny=min(centroids(:,2));
maxy=max(centroids(:,2));

%Make a mesh using the values with z > 0
[X,Y]=meshgrid(minx:.1:maxx,miny:.1:maxy);
Z = griddata(zpts(:,1),zpts(:,2),zpts(:,3),X,Y); %#ok<GRIDD>
mesh(X,Y,Z)

%Plot the x,y data
hold
plot3(zpts(:,1),zpts(:,2),zpts(:,3),'.')
%Interpolate z-values for all the x,y locations
ZI=interp2(X,Y,Z,centroids(:,1),centroids(:,2));
plot3(centroids(:,1),centroids(:,2),ZI,'.')
axis equal; %You can toggle this off the see exaggerated height
hold off

%Catenate the interpolated z-values to the x,y locations
outmat=horzcat(centroids(:,1),centroids(:,2),ZI);
%Flag any NotANumbers (NANs)and set to zero
outmat(find(isnan(outmat(:,3))),3)=0.0;

%Write the output text file
dlmwrite('BackGS5Data.txt',outmat,'newline','pc');