% Turn the scanned point data into a surface
g=regularizeNd([x,y] ,z, {gx,gy}, smoothness);
% g=regularizeNd([x,y] ,z, {gx,gy}, smoothness, 'linear');
% g=regularizeNd([x,y] ,z, {gx,gy}, smoothness, 'linear', 'normal');
% g=regularizeNd([x,y] ,z, {gx,gy}, smoothness, 'cubic');
% g=regularizeNd([x,y] ,z, {gx,gy}, smoothness, 'cubic', 'normal');
% g=regularizeNd([x,y] ,z, {gx,gy}, smoothness, 'cubic', '\');
line(x,y,z,'marker','.','markersize',4,'linestyle','none');
title 'Use topographic contours to recreate a surface'
z = sin(4*x+5*y).*cos(7*(x-y))+exp(x+y);
zgd = griddata(x,y,z,xg,yg);
title 'Griddata on trig surface'
% Note the wing-like artifacts along the edges, due
% to the use of a Delaunay triangulation in griddata.
zGrid = regularizeNd([x,y], z, xGrid, smoothness);
title(sprintf('regularizeNd to trig surface, smoothness=%g', smoothness))
% griddata has problems with badly scaled data
[xg,yg]=meshgrid(xis,yis);
zgd = griddata(xs,ys,z,xg,yg);
title 'Serious problems for griddata on badly scaled trig surface'
% No need for scaling with regularizeNd
zgrids = regularizeNd([xs,ys],z,{xis,yis}, smoothness);
title(sprintf('regularizeNd on badly scaled trig surface, smoothness=%g', smoothness))
zpgf = regularizeNd([x,y],z,{xi,xi}, smoothness, 'cubic');
zpgd = griddata(x,y,z,xg,yg,'cubic');
title 'Griddata (method == cubic) on peaks surface'
title('regularizeNd with cubic interp method to peaks surface')
% gridfit had a option called tiles. It was made for handling large
% problems. However, no option like this exists in regularizeNd. The case
% here the is no longer of severe consequence. The problem solves in a few
% seconds. I have solved problems with as many as 3000 grid points (2e6
% unknowns) in each dimension in under a minute.
z = x+y+sin((x.^2+y.^2)*10);
zg = regularizeNd([x,y], z, {xnodes,ynodes}, smoothness);
toc;
Elapsed time is 6.786547 seconds.
surf(xnodes, ynodes, zg')
title 'No need for tiles with regularizeNd'