源程序
clear
clc
x=[ 60 55 59 51 44 39 37 36 29 44 37 0 12 14 19 19 17 1 23 23 27 14 15 18 24 29 36 39 37 28 21 18 15 65 61 58 55 54 52 52 52 46 51 52 ];%输入x坐标数据
y=[ 0 17 20 18 19 19 21 12 12 8 1 0 16 25 20 13 5 0 4 11 8 12 38 27 24 24 20 27 33 37 18 15 20 59 47 40 43 46 42 48 52 48 39 36 ];% 输入y坐标数据
z=[ 18 17 18 18 18 18 19 17 18 17 17 17 17 16 17 17 18 17 17 18 17 17 16 17 17 18 19 18 17 17 17 17 17 18 17 18 18 18 18 18 17 17 19 19 ];% 输入z坐标数据
[X,Y]=meshgrid(min(x):0.2:max(x),min(y):0.2:max(y)); %加密网格
Z=griddata(x,y,z,X,Y,'v4');%在加密网格处取Z值
figure(1);
surf(X,Y,Z);%画三维图
xlabel('X','fontsize',12,'fontweight','b','color','r');
ylabel('Y','fontsize',12,'fontweight','b','color','r');
zlabel('高程','fontsize',12,'fontweight','b','color','r');
hold on;
plot3(x,y,z,'*');%表示出原始数据点
hold off;
figure(2);
[C,h] = contour(X,Y,Z);%画等高线图
set(h,'ShowText','on','TextStep',get(h,'LevelStep')*2)
colormap cool