matlab三维图代码.doc
文本预览下载声明
1.
generate grid
[x,y] = meshgrid(x, y);
read excel data
z1 = xlsread(data.xls);
z1(1 , :) = [];
z1(: , 1) = [];
z = z1;
change the rows
a = 1 : 21;
a1 = 21 : -1 : 1;
z(a, :) = z(a1, :);
% mesh the result
figure(1)
mesh(x,y,z)
plot the contour
figure(2)
contour(x,y,z)
colorbar
2
clear;
clf;
X=[1200 1600 2000 2400 2800 3200 3600 4000];
Y=[3600 3200 2800 2400 2000 1600 1200];
%[X,Y]=meshgrid(x,y);
Z=[1480 1500 1550 1510 1430 1300 1200 980
1500 1550 1600 1550 1600 1600 1600 1550
1500 1200 1100 1550 1600 1550 1380 1070
1500 1200 1100 1350 1450 1200 1150 1010
1390 1500 1500 1400 900 1100 1060 950
1320 1450 1420 1400 1300 700 900 850
1130 1250 1280 1230 1040 900 500 700];
figure(1)
subplot(2,2,1)
contour(X,Y,Z,16)
title(等高线1)
xlabel(x-axis)
ylabel(y-axis)
subplot(2,2,3)
contour3(X,Y,Z,16)
title(等高线2)
xlabel(x-axis)
ylabel(y-axis)
zlabel(z-axis)
subplot(2,2,2)
surf(X,Y,Z)
title(地貌图1)
xlabel(x-axis)
ylabel(y-axis)
zlabel(z-axis)
subplot(2,2,4)
surfc(X,Y,Z)
title(地貌图2)
xlabel(x-axis)
ylabel(y-axis)
zlabel(z-axis)
figure(2)
subplot(2,2,1)
contour(X,Y,Z,16)
title(等高线1)
xlabel(x-axis)
ylabel(y-axis)
rotate3d
subplot(2,2,3)
contour3(X,Y,Z,16)
title(等高线2)
xlabel(x-axis)
ylabel(y-axis)
zlabel(z-axis)
rotate3d
subplot(2,2,2)
surf(X,Y,Z)
title(地貌图)
xlabel(x-axis)
ylabel(y-axis)
zlabel(z-axis)
rotate3d
subplot(2,2,4)
surfc(X,Y,Z)
title(地貌图2)
xlabel(x-axis)
ylabel(y-axis)
zlabel(z-axis)
rotate3d
figure(3)
subplot(2,2,1)
surf(X,Y,Z)
title(地貌图1)
xlabel(x-axis)
ylabel(y-axis)
zlabel(z-axis)
subplot(2,2,2)
surfc(X,Y,Z)
title(地貌图2)
xlabel(x-axis)
ylabel(y-axis)
zlabel(z-axis)
subplot(2,2,3)
surfl(X,Y,Z)
title(地貌图3)
xlabel(x-axis)
ylabel(y-axis)
zlabel(z-axis)
figure(4)
subplot(2,2,1)
surf(X,Y,Z)
title(地貌图1)
xlabel(x-axis)
ylabel(y-axis)
zlabel(z-axis)
rotate3d
subplot(2,2,2)
surfc(X,Y,Z)
title(地貌图2)
xlabel(x-axis)
ylabel(y-axis)
zlabel(z-axis)
rotate3d
subplot(2,2,3)
surfl(X,Y,Z)
title(地貌图3)
xlabel(x-axis)
ylabel(y-axis)
zlabel(z-axis)
rotate3d
3
% 读取图象数据到矩阵 [A, HYPERLINK /other-data
显示全部