MATLAB绘图

基本绘图函数

  1. 正/余弦函数
clear all;
t = 0.1:0.02:2*pi;
figure;
plot(t, sin(t), 'r:');
hold on;
plot(t, cos(t))
xlabel('x')
ylabel('y')
title('plot')

运行结果:
在这里插入图片描述
2. 绘制矩阵

clear all;
y=magic(4); %%4行4列的矩阵
figure;
plot(y);  %%对每一列绘制一条线,即4条,每条4个点,默认颜色不同

magic(4)
ans =
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
在这里插入图片描述

  1. 绘制矩阵
clear all;
x=0:0.1:16;
y=sin(x);
figure;
plot(x,y);

运行结果:
在这里插入图片描述
4. 绘制红色线型

clear all;
x=0.01:0.1:2*pi;
y=cos(x+0.7)+5
figure;
plot(x,y,'r-.*');

绘制结果:
在这里插入图片描述
5. 绘制绿色线型三角标志

clear all;
x=0.01:0.2:6*pi
y=cos(x);
figure;
plot(x,y,'g:^');

绘制结果:
在这里插入图片描述
6. 设置绘制标志的大小、边缘/轮廓颜色

clear all;
x=-pi:pi/20;pi
y=tan(sin(x))-sin(tan(x))
plot(x,y,'--rs','LineWidth',1,...
                'MarkerEdgeColor','k',...
                'MarkerFaceColor','g',...
                'MarkerSize',4);

绘制结果:
在这里插入图片描述
7. 同时绘制多条曲线

x=-pi:pi/20:pi
y=sin(x);
z=cos(x)
figure;
plot(x,y,'r:*',x,z,'g-.v')

绘制结果:
在这里插入图片描述

MATLAB子图绘制和坐标轴控制

1.绘制子图

x=-pi:pi/20:pi;
figure
subplot(2,1,1);
plot(x,sin(x),'r--')
subplot(212);
plot(x,cos(x),'b:*')

绘制结果:
在这里插入图片描述

2.绘制多种子图

x=-pi:pi/20:pi;
figure
subplot(2,2,1);
plot(x,sin(x),'r--')
subplot(223);
plot(x,cos(x),'b:*')
subplot(2,2,[2 4]);
plot(x,sin(x)+cos(x),'b-.^');

在这里插入图片描述

2.绘制多种子图

t=0.01:0.01:pi;
figure
subplot(2,2,1);
plot(x,sin(x),'r--')
subplot(223);
plot(x,cos(x),'b:*')
subplot(2,2,[2 4]);
plot(x,sin(x)+cos(x),'b-.^');0.01:pi
figure;
plot(sin(t),cos(t))
axit #设置坐标轴 获取当前坐标值

在这里插入图片描述
3.绘制多种图像

t=0.01:0.01:pi;
figure
plot(sin(t),cos(t))
axis off

在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值