MATLAB三维图和子图

三维曲面图

surf函数可用来做三维曲面图。一般是展示z = z(x,y)的图像
首先需要用meshgrid创建好空间上(x,y)点。

clc,clear
[X,Y] = meshgrid(-2:0.2:2);
%Z = X.^2+Y.^2
Z = X.*exp(-X.^2-Y.^2);
surf(X,Y,Z);

%colormap hsv    %colormap设置颜色,可跟winter,summer
%colobar

子图

使用subplot函数可以在同一窗口的不同子区域显示多个绘图

clc,clear
[X,Y] = meshgrid(-2:0.2:2);
theta = 0:0.01:2*pi;
radi = abs(sin(2*theta).*cos(2*theta));
Height = randn(1000,1);
Weight = randn(1000,1);

subplot(2,2,1);surf(X.^2);title('1st');
subplot(2,2,2);surf(Y.^3);title('2nd');
subplot(2,2,3);polarplot(theta,radi);title('3rd');
subplot(2,2,4);scatter(Height,Weight);title('4th');
posted @ 2022-04-18 15:28  又一岁荣枯  阅读(195)  评论(0编辑  收藏  举报