matlab 图形绘制(基础篇)

【参考教学视频:https://www.bilibili.com/video/av14503445/?p=5】

目录

plot()

plot指定 形状:

 text() 、annotation():

更改图像的性质:

​ 

 更改特性:

 marker:(点的特性)

 同时画多个图(不被覆盖):

在一个plot画多个figure:

将画出的图像保存:


plot()

matlab 在画图是会将前面的图覆盖掉,除非用hold on 和 hold off

(通过hold on 可以将多条线画在同一个图形之中)

plot指定 形状:

如:

(1)

hold on;
plot(cos(0:pi/20:2*pi),'or--');
plot(sin(0:pi/20:2*pi),'xg:');
hold off;

(2) 

x = 0:0.5:4*pi;
y = sin(x);
h = cos(x);
w = 1./(1+exp(-x));
g = (1/(2*pi*2)^0.5).*exp((-1.*(x-2*pi).^2)./(2*2^2));
plot(x,y,'bd-',x,h,'gp:',x,w,'ro-',x,g,'c^-');

(3)

plot(x, y1,'--*',x,y2,':o');
xlabel('t = 0 to 2\pi');
ylabel('values of sin(t) and e^{x}');
title('Function Plots of sin(t) and e^{x}');
legend('sin(t)','e^{x}');

 

 

 text() 、annotation():

例如:

clc ;
clear;
x = linspace(0,3);
y = x.^2.*sin(x);
plot(x,y);
line([2,2],[0,2^2*sin(2)]);
str = '$$ \int_{0}^{2} x^2\sin(x) dx $$';
text(0.25,2.5,str,'Interpreter','latex');
annotation('arrow','X',[0.32,0.5],'Y',[0.6,0.4]);

 

str = '$$ \int_{0}^{2} x^2\sin(x) dx $$';
text(0.25,2.5,str,'Interpreter','latex');

——>积分公式的显示

annotation('arrow','X',[0.32,0.5],'Y',[0.6,0.4]); ——>箭头。

【练习】

clc ;
clear;
x = 1:0.02:2;
y1 = x.^2;
y2 = sin(2*pi.*x);
plot(x,y1,'-k',x,y2,'or');
ylabel('f(t)');
xlabel('Time(ms)');
title('Mini Assignment #1');
legend('{t}^2','sin(2\pi{t})');

更改图像的性质:

如:

  • 2
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值