%Gridfitdemoscript%Thisscriptfileisdesignedtobeusedincellmode%fromthematlabeditor,orbestofall,usethepublish%%ofmatlabcancopyandpasteentireblocksofcodeinto%;x=bluff_data(:,1);y=bluff_data(:,2);z=bluff_data(:,3);%%(x,y,z,'.')%Turnthescannedpointdataintoasurfacegx=0:4:264;gy=0:4:400;g=gridfit(x,y,z,gx,gy);figurecolormap(hot(256));surf(gx,gy,g);camlightright;lightingphong;shadinginterpline(x,y,z,'marker','.','markersize',4,'linestyle','none');title'ontourstorecreateasurface'Fittingatrigonometricsurfaceclearn1=15;n2=15;theta=rand(n1,1)*pi/2;r=rand(1,n2);x=cos(theta)*r;y=sin(theta)*r;x=x(:);y=y(:);x=[[0011]';x;x;1-x;1-x];y=[[0101]';y;1-y;y;1-y];figureplot(x,y,'.')title'Datalocationsinthex-yplane'z=sin(4*x+5*y).*cos(7*(x-y))+exp(x+y);xi=linspace(0,1,51);[xg,yg]=meshgrid(xi,xi);zgd=griddata(x,y,z,xg,yg);figuresurf(xi,xi,zgd)colormap(hot(256))camlightrightlightingphongtitle'Griddataontrigsurface'%Notethewing-likeartifactsalongtheedges,due%=gridfit(x,y,z,xi,xi);figuresurf(xi,xi,zgrid)colormap(hot(256))camlightrightlightingphongtitle('Gridfittotrigsurface')Thetrigsurfacewithhighlydifferentscalingsonthexandyaxesxs=x/100;xis=xi/100;ys=y*100;yis=xi*100;%griddatahasproblemswithbadlyscaleddata[xg,yg]=meshgrid(xis,yis);zgd=griddata(xs,ys,z,xg,yg);figuresurf(xg,yg,zgd)colormap(hot(256))camlightrightlightingphongtitle'riddataonbadlyscaledtrigsurface'%autoscalingon(thedefault)zgrids=gridfit(xs,ys,z,xis,yis,'autoscale','on');%plottheautoscaledresultfiguresurf(xis,yis,zgrids)colormap(hot(256))camlightrightlightingphongtitle'Gridfit(automaticallyscaled)ontrigsurface'Warning:Duplicatex-ydatapointsdetected:"peaks"surfaceclearn=100;x=(rand(n,1)-.5)*6;y=(rand(n,1)-.5)*6;z=peaks(x,y);xi=linspace(-3,3,101);zpgf=gridfit(x,y,z,xi,xi);[xg,yg]=meshgrid(xi,
matlab程序曲面拟合 来自淘豆网www.taodocs.com转载请标明出处.