数学建模MATLAB绘图大全

最近快要开始一年一度的数学建模竞赛啦,接下来争取每天更一篇数学建模算法!(当然这是理想状态下),今天就先更一些MATLAB常用的绘图吧,论文赏心悦目的关键就在于丰富多彩的图,好看的图一定会成为数学建模竞赛中的加分项!

1. ****二维绘图函数

示例:

Matlab 复制代码
clc,clear,
syms x y,
ezplot(x^2-y^4)

2.三维绘图函数

示例:

Matlab 复制代码
syms t
ezplot3(sin(t),cos(t),t,[0,6*pi],"animate")

3.等高线绘图函数

示例:

Matlab 复制代码
clc,clear,
syms x y,
f=3*(1-x)^2*exp(-(x^2)-(1+y)^2)-10*(x/5-x^3-y^5)*exp(-x^2-y^2)...
    -1/3*exp(-(x+1)^2-y^2);
ezcontour(f,[-3,3],49)

填充等高线图

Matlab 复制代码
clc,clear,
syms x y,
f=3*(1-x)^2*exp(-(x^2)-(1+y)^2)-10*(x/5-x^3-y^5)*exp(-x^2-y^2)...
    -1/3*exp(-(x+1)^2-y^2);
ezcontourf(f,[-3,3],49)

4.网格图绘图函数

ezmesh函数

Matlab 复制代码
clc,clear,
syms x y,
ezmesh(x*exp(-x^2-y^2),[-2.5,2.5],40)

5.表面图绘图函数

Matlab 复制代码
clc,clear;
syms s t,
x=cos(s)*cos(t);
y=cos(s)*sin(t);
z=sin(s);
ezsurf(x,y,z,[0,pi/2,0,3*pi/2])
view(17,40)
shading interp

6.plot函数绘图

参数介绍:

示例:

Matlab 复制代码
clc,clear,
x=linspace(0,7);
y1=sin(2.*x);
y2=sin(x.^2);
y3=(sin(x)).^2;
plot(x,y1,'r+-',x,y2,'k*:',x,y3,'b--^')
legend('sin(2*x)','sin(x^2)','(sin(x))^2')
xlabel('x轴')
ylabel('y轴')
grid on

7.subplot的使用

示例:

Matlab 复制代码
x=-10:0.1:10;
y1=x.*cos(x);
y2=-x.*sin(x)+cos(x);
y3=cos(x).*sin(x);
y4=sin(x).^2;
subplot(2,2,1)
plot(x,y1)
title('图1')
subplot(2,2,2);
plot(x,y2,'b--')
title('图2')
subplot(2,2,3)
plot(x,y3,'mo')
title('图3')
subplot(2,2,4)
plot(x,y4,'g*')
title('图4')

8.hold的使用

Matlab 复制代码
clc,clear;
t=0:pi/10:2*pi;
y1=sin(t);
y2=cos(t);
y3=sin(t)-cos(t);
plot(t,y1,'g*');
hold on;
plot(t,y2,'-.b');
plot(t,y3,'--m');

9.三维绘图

示例:

Matlab 复制代码
x=0:0.1:10;
[x,y]=meshgrid(linspace(0,10),linspace(0,10));
z=(1./(x.^3-2.*x+5))+(1./(y.^3-2.*y+5));
mesh(x,y,z);
xlabel('X');
ylabel('Y');
zlabel('Z');
grid on
Matlab 复制代码
x=-8:0.5:8;
y=x;
[X,Y]=meshgrid(x,y);
r=sqrt(X.^2+Y.^2)+eps;
Z=sin(r)./r;
surf(X,Y,Z);
Matlab 复制代码
t=0:pi/50:10*pi;
x=exp(-t/15).*sin(2*t);
y=exp(-t/15).*cos(2*t);
z=t;
plot3(x,y,z)
axis square;
grid on

经典图:

Matlab 复制代码
z=peaks(40);
surf(z); 
Matlab 复制代码
clear;
z=peaks(40);
subplot(2,2,1);
mesh(z)
subplot(2,2,2);
mesh(z)
view(-15,60);
subplot(2,2,3);
mesh(z)
view(-90,0);
subplot(2,2,4);
mesh(z)
view(-7,-10);

10.时间响应绘图

​​参数介绍:

示例:

Matlab 复制代码
clear;
num1=[0 0 1];num2=[0 1 0];num3=[1 0 0];
den=[1 2 10]; 
impulse(num1,den);
hold on
gtext('G1')
impulse(num2,den);
gtext('G2')
impulse(num3,den);
gtext('G3')
相关推荐
松果集几秒前
MATLAB基础知识【8】绘图,peaks,sphere,积分
matlab
醇醛酸醚酮酯17 分钟前
Qt项目锻炼——TODO清单(二)
开发语言·数据库·qt
jioulongzi22 分钟前
记录一次莫名奇妙的跨域502(badgateway)错误
开发语言·python
向阳@向远方1 小时前
第二章 简单程序设计
开发语言·c++·算法
Mr_Xuhhh1 小时前
信号与槽的总结
java·开发语言·数据库·c++·qt·系统架构
纳兰青华2 小时前
bean注入的过程中,Property of ‘java.util.ArrayList‘ type cannot be injected by ‘List‘
java·开发语言·spring·list
wwer1425263632 小时前
数学建模_时间序列
数学建模
好开心啊没烦恼2 小时前
Python 数据分析:DataFrame,生成,用字典创建 DataFrame ,键值对数量不一样怎么办?
开发语言·python·数据挖掘·数据分析
liulilittle2 小时前
VGW 虚拟网关用户手册 (PPP PRIVATE NETWORK 基础设施)
开发语言·网络·c++·网关·智能路由器·路由器·通信
Devil枫2 小时前
Kotlin高级特性深度解析
android·开发语言·kotlin