注册 登录
编程论坛 Matlab

函数griddata的超牛改进版,值得一下哦

hitzhang 发布于 2008-11-09 16:10, 8569 次点击
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录
16 回复
#2
meteora11062008-11-09 19:54
仁兄,你给大家简要介绍一下么,这是个什么东东。
#3
hitzhang2008-11-09 21:32
% Gridfit demo script

% This script file is designed to be used in cell mode
% from the matlab editor, or best of all, use the publish
% to HTML feature from the matlab editor. Older versions
% of matlab can copy and paste entire blocks of code into
% the Matlab command window.

Topographic dataload bluff_data;
x=bluff_data(:,1);
y=bluff_data(:,2);
z=bluff_data(:,3);
% Two ravines on a hillside. Scanned from a
% topographic map of an area in upstate New York.
plot3(x,y,z,'.')

只有本站会员才能查看附件,请 登录

% Turn the scanned point data into a surface
gx=0:4:264;
gy=0:4:400;
g=gridfit(x,y,z,gx,gy);
figure
colormap(hot(256));
surf(gx,gy,g);
camlight right;
lighting phong;
shading interp
line(x,y,z,'marker','.','markersize',4,'linestyle','none');
title 'Use topographic contours to recreate a surface'

只有本站会员才能查看附件,请 登录

Fitting a trigonometric surfaceclear

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 = [[0 0 1 1]';x;x;1-x;1-x];
y = [[0 1 0 1]';y;1-y;y;1-y];
figure
plot(x,y,'.')
title 'Data locations in the x-y plane'

只有本站会员才能查看附件,请 登录

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);

figure
surf(xi,xi,zgd)
colormap(hot(256))
camlight right
lighting phong
title 'Griddata on trig surface'
% Note the wing-like artifacts along the edges, due
% to the use of a Delaunay triangulation in griddata.
只有本站会员才能查看附件,请 登录

zgrid = gridfit(x,y,z,xi,xi);

figure
surf(xi,xi,zgrid)
colormap(hot(256))
camlight right
lighting phong
title('Gridfit to trig surface')

只有本站会员才能查看附件,请 登录

The trig surface with highly different scalings on the x and y axesxs = x/100;
xis = xi/100;

ys = y*100;
yis = xi*100;

% griddata has problems with badly scaled data
[xg,yg]=meshgrid(xis,yis);
zgd = griddata(xs,ys,z,xg,yg);

figure
surf(xg,yg,zgd)
colormap(hot(256))
camlight right
lighting phong
title 'Serious problems for griddata on badly scaled trig surface'

% autoscaling on (the default)
zgrids = gridfit(xs,ys,z,xis,yis,'autoscale','on');

% plot the autoscaled result
figure
surf(xis,yis,zgrids)
colormap(hot(256))
camlight right
lighting phong
title 'Gridfit (automatically scaled) on trig surface'

只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录

Fitting the "peaks" surfaceclear

n = 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');

figure
surf(xi,xi,zpgd)
colormap(jet(256))
camlight right
lighting phong
title 'Griddata (method == cubic) on peaks surface'

figure
surf(xi,xi,zpgf)
colormap(hsv(256))
camlight right
lighting phong
title('Gridfit to peaks surface')

只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录
#4
Stirling2008-11-20 08:28
能详细的解释一下么?没看懂什么意思。。。
#5
hitzhang2008-11-20 12:27
我的理解,gridata是把一块有限大的布铺在数据点上,而这个改进的函数是把一块无限大的木板钉在数据点上,这样看起来不仅曲面很光滑而且可以外推作简单的预报。来自www.
#6
pocy2011-09-10 08:37
恩 太有才了 真的不错~
#7
jeanine1232011-10-15 11:21
学习一下,谢谢楼主分享成果。
#8
ejiuguniang2012-03-06 15:39
下载了回帖下  顶起
#9
billxiao10212012-04-18 21:04
非常好,谢谢你的分享!
#10
jiatianjie2012-09-02 15:07
程序下载下来应该怎么用啊。。。楼主教教新人吧
#11
LHLX2013-06-27 09:51
这么用啊这个?哪位大神说一声啊?
#12
huohy2014-03-22 18:01
下载了,使用了,好用。
#13
lwrxzl2014-05-14 20:49
谢谢楼主分享···
#14
吴施楷2014-10-09 21:23
谢谢,很有用
#15
zjr0750172015-01-28 09:51
回复 楼主 hitzhang
下载顶起!
#16
水灵召唤2015-05-31 15:27
回复 10楼 jiatianjie
自己改变量就行了吧
#17
oceanyang2015-07-17 00:24
x=0:400:5600;
y=0:400:4800;
z=[370 470 550 600 670 690 670 620 580 450 400 300 100 150 250
   510 620 730 800 850 870 850 780 720 650 500 200 300 350 320
   650 760 880 970 1020 1050 1020 830 800 700 300 500 550 480 350
   740 880 1080 1130 1250 1280 1230 1040 900 500 700 780 750 650 550
   830 980 1180 1320 1450 1420 1400 1300 700 900 850 840 380 780 750
   880 1060 1230 1390 1500 1500 1400 900 1100 1060 950 870 900 930 950
   910 1090 1270 1500 1200 1100 1350 1450 1200 1150 1010 880 1000 1050 1100
   950 1190 1370 1500 1200 1100 1550 1600 1550 1380 1070 900 1050 1150 1200
   1430 1450 1460 1500 1550 1600 1550 1600 1600 1600 1550 1500 1500 1550 1500
   1420 1430 1450 1480 1500 1550 1510 1430 1300 1200 980 850 750 550 500
   1380 1410 1430 1450 1470 1320 1280 1200 1080 940 780 620 460 370 350
   1370 1390 1410 1430 1440 1140 1110 1050 950 820 690 540 380 300 210
   1350 1370 1390 1400 1410 960 940 880 800 690 570 430 290 210 150
];
xi=0:4:5600;
yi=0:4:4800;
[xii,yii]=meshgrid(xi,yi);
zii=gridfit(x,y,z,xii,yii);
楼主能帮忙看看这么写报错了
1