该【matlab程序曲面拟合 】是由【guoxiachuanyue011】上传分享,文档一共【14】页,该文档可以免费在线阅读,需要了解更多关于【matlab程序曲面拟合 】的内容,可以使用淘豆网的站内搜索功能,选择自己适合的文档,以下文字是截取该文章内的部分文字,如需要获得完整电子版,请下载此文档到您的设备,方便您编辑和打印。%Gridfitdemoscript%Thisscriptfileisdesignedtobeusedincellmode
%fromthematlabeditor,orbestofall,usethepublish%
%ofmatlabcancopyandpasteentireblocksofcodeinto%theMatlabcommandwindow.
Topographicdata
loadbluff_data;
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;
shadinginterp
line(x,y,z,'marker','.','markersize',4,'linestyle','none');
title'Usetopographiccontourstorecreateasurface'
100
0
300
200
Useiopographioontourstorecreateasurface
300...
200、一
150■_
50、一
200
100
-50
400
300
250
一一VISO
■■■'100
50
Fittingatrigonometricsurface
clear
n1=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];
figure
plot(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%totheuseofaDelaunaytriangulationingriddata.
8
6
5
3
0
02
Griddaiaiontrig"3ui;faEp
zgrid=gridfit(x,y,z,xi,xi);
figure
surf(xi,xi,zgrid)colormap(hot(256))camlightrightlightingphongtitle('Gridfittotrigsurface')
8
6
5
3
2
0
04
Cridfittotrigsurface
Thetrigsurfacewithhighlydifferentscalingsonthexandy
axes
xs=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'Seriousproblemsforgriddataonbadlyscaledtrigsurface'
%autoscalingon(thedefault)
zgrids=gridfit(xs,ys,z,xis,yis,'autoscale','on');
%plottheautoscaledresult
figuresurf(xis,yis,zgrids)colormap(hot(256))camlightrightlightingphongtitle'Gridfit(automaticallyscaled)ontrigsurface'
Warning:Duplicatex-ydatapointsdetected:usingaverageofthezvalues.
8
6
5
3
2
SO
60
40
20
Seriousproblemsforgriddataonbadlyscaledtrigsurfece
■■-
片'
"-
□.DO?-
Gridfit(automaticallyscaled)ortrigsurfect
0
100
□.DO?-
□0
Fittingthe"peaks"surface
clearn=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,xi);zpgd=griddata(x,y,z,xg,yg,'cubic');
figuresurf(xi,xi,zpgd)colormap(jet(256))
camlightright
lightingphong
title'Griddata(method==cubic)onpeakssurface'
figuresurf(xi,xi,zpgf)colormap(hsv(256))
camlightright
lightingphongtitle('Gridfittopeakssurface')
matlab程序曲面拟合 来自淘豆网www.taodocs.com转载请标明出处.