matlab 三维画图总结

1.画函数的三维图,如:Z(X,Y)=2*X.*exp(-X.^2-Y.^2)+1;

close all;
[X,Y]=meshgrid(-2:0.5:2,-2:0.5:2);%生成坐标轴
Z=2*X.*exp(-X.^2-Y.^2)+1;%Z是X,Y的函数
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
num=0;
num=num+1;
subplot(2,3,num);
plot3(X,Y,Z);
axis([-3 3 -3 3 0 2]);%限定显示的范围
xlabel('x轴');%x轴坐标
ylabel('y轴');%y轴坐标
zlabel('z轴');%z轴坐标
title('http://blog.csdn.net/nuptboyzhb/   figure(1)');%标题
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
num=num+1;
subplot(2,3,num);
mesh(X,Y,Z);
axis([-3 3 -3 3 0 2]);%限定显示的范围
xlabel('x轴');%x轴坐标
ylabel('y轴');%y轴坐标
zlabel('z轴');%z轴坐标
title('http://blog.csdn.net/nuptboyzhb/   figure(2)');%标题
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
num=num+1;
subplot(2,3,num);
meshc(X,

你可能感兴趣的:(matlab)