sdccumcm 发表于 2012-2-3 16:59

一个关于插值的matlab程序问题

例 山区地貌:
   在某山区测得一些地点的高程如下表。平面区域为
           1200<=x<=4000,1200<=y<=3600)
试作出该山区的地貌图和等高线图,并对几种插值方法进行比较。

    X
Y        1200        1600        2000        2400        2800        3200        3600        4000
1200        1130        1250        1280        1230        1040        900        500        700
1600        1320        1450        1420        1400        1300        700        900        850
2000        1390        1500        1500        1400        900        1100        1060        950
2400        1500        1200        1100        1350        1450        1200        1150        1010
2800        1500        1200        1100        1550        1600        1550        1380        1070
3200        1500        1550        1600        1550        1600        1600        1600        1550
3600        1480        1500        1550        1510        1430        1300        1200        980

下面是照着书上打下来的代码,运行之后报错,想请高手们帮忙看看:
x=0:400:5600;
y=0:400:4800;
z=[1130        1250        1280        1230        1040        900        500        700
1320        1450        1420        1400        1300        700        900        850
1390        1500        1500        1400        900        1100        1060        950
1500        1200        1100        1350        1450        1200        1150        1010
1500        1200        1100        1550        1600        1550        1380        1070
1500        1550        1600        1550        1600        1600        1600        1550
1480        1500        1550        1510        1430        1300        1200        980];
%用原始数据作山区表面图
figure(1);
meshz(x,y,z)
xlabel('X'),ylabel('Y'),zlabel('Z')
%每隔50加密网络,分别作最近点插值、双线性插值和双三次插值,做出插值后的表面图
xi=0:50:5600;
yi=0:50:4800;

figure(2)
z1i=interp2(x,y,z,xi,yi,'nearest');%最近点插值
surfc(xi,yi,z1i)
xlabel('X'),ylabel('Y'),zlabel('Z')

figure(3)
z2i=interp2(x,y,z,xi,yi,'linear');%线性插值
surfc(xi,yi,z2i)
xlabel('xx'),ylabel('yy'),z;ane;('zz')

figure(4)
z3i=interp2(x,y,z,xi,yi,'cubic')%三次插值
surfc(xi,yi,z3i)
xlabel('**'),ylabel('yyy'),zlabel('zzz')

figure(5)
suplot(1,3,1),contour(xi,yi,z1i,10,'r');
suplot(1,3,2),contour(xi,yi,z2i,10,'r');
suplot(1,3,3),contour(xi,yi,z3i,10,'r');


还有一个问题就是,我在运行这样几个语句时,系统报错了,分析过后可能是我自己电脑的问题,但是又查不出来:
>> x=1:5;
>> yy=1:3;
>> temps=;
>> mesh(x,y,temps)
??? Undefined function or method 'usev6plotapi' for input arguments of type 'double'.

Error in ==> mesh at 53
= usev6plotapi(varargin{:},'-mfilename',mfilename);

谢谢!

李——建辉 发表于 2012-2-3 19:43

特意来佩服一下···401842064618743749216563207627303297359495429075897925516987348927616539792984

sdccumcm 发表于 2012-2-19 12:15

{:3_42:}{:3_60:}{:3_60:}{:3_60:}{:3_60:}{:3_60:}

zmssorry 发表于 2012-2-21 10:09

数据格式不匹配

sdccumcm 发表于 2012-2-21 10:56

喔~~好的 谢谢

wyanxia 发表于 2012-2-21 11:08

路过,插值方法都快忘记了

新生泪 发表于 2012-2-21 15:42

usev6plotapi没有用过啊

紫藤恋晴天 发表于 2012-8-16 13:32

你仔细看了你的程序没有?细看一下你就会发现你的z的取值不够(你看看你的原题,我没有所以具体不知道),还有就是你的z2i=interp2(x,y,z,xi,yi,'linear)中的yi应该是其转自(字打错了)也就是yi'的'

sdccumcm 发表于 2012-8-16 14:44

紫藤恋晴天 发表于 2012-8-16 13:32 static/image/common/back.gif
你仔细看了你的程序没有?细看一下你就会发现你的z的取值不够(你看看你的原题,我没有所以具体不知道),还 ...

明白了  多谢了!

生于青春 发表于 2012-8-16 15:48

{:3_41:}{:3_42:}{:3_46:}{:3_48:}{:3_55:}{:3_53:}{:3_50:}{:3_49:}{:3_59:}{:3_60:}{:3_61:}{:3_64:}
页: [1] 2
查看完整版本: 一个关于插值的matlab程序问题