This file has been updated for a MUCH faster version on large arrays (100k elements plus).
MATLABs most commonly used 3-d plotting tools surf and mesh require rectangular grids to plot in 3-d, not x,y,z triples. This function converts arrays of x,y,z triples into rectangular grids to use with surf, mesh, etc.
[x y z] = xyzplotter(xin,yin,zin)
xin,yin,zin are n x 1 arrays that define your surface. So xin(1),yin(1),zin(1) is the first point in your surface, etc. They do not need to be in any particular order.
Missing values in the grid will be filled in with NaNs. If you would like to interpolate the NaNs, I suggest inpaint_nans, file exchange number 4551. Here is the link:
Andrew Stephens contributed some good ideas to this code, mostly accumarray() and unique() which I didn't know existed before. For now I would like to acknowledge his generous contribution.