代码成就万世基积沙镇海,梦想永在凌云意意|

又一岁荣枯

园龄:3年4个月粉丝:11关注:6

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');

本文作者:又一岁荣枯

本文链接:https://www.cnblogs.com/java-six/p/16159878.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   又一岁荣枯  阅读(201)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起