matlab基础操作(七)

41.重绘曲线

Exam:重绘波形y=sin(t)sin(9t)及其包络线。

>> plot(t,y1,'r:')

>> hold on

>> plot(t,y2,'b')

>> plot(t3,y3,'bo')

>> axis([0,pi,-1,1])

>> hold off

42.利用hold绘制离散信号的波形

>> t=2*pi*(0:20)/20;

>> y=cos(t).*exp(-0.4*t);

>> stem(t,y,'g');

>> hold on

>> stairs(t,y,'r');

>> hold off

43.双纵坐标:plotyy指令

调用格式:plotyy(x1,y1,x2,y2),x1-y1曲线y轴在左,x2-y2曲线y轴在右

>> x=0:0.01:20;

>> y1=200*exp(-0.05*x).*sin(x);

>> y2=0.8*exp(-0.5*x).*sin(10*x);

>> plotyy(x,y1,x,y2);

44.多子图

subplot(m,n,k):使(m*n)幅子图中第k个子图成为当前图;其编号原则:左上方为第1子图,然后向右向下一次排序。

subplot('position',[left,bottom,width,height]):在指定的位置上开辟子图,并成为当前图;用于手工指定子图位置,指定位置的四元组采

用归一化的标称单位,即认为整个图形窗口绘图区域的高、宽的取值范围都是[0,1],而左下角为(0,0)坐标。

>> t=(pi*(0:1000)/1000)';

>> y1=sin(t);

>> y2=sin(10*t);

>> y12=sin(t).*sin(10*t);

>> subplot(2,2,1);

>> subplot(2,2,1),plot(t,y1);

>> axis([0,pi,-1,1])

>> subplot(2,2,2),plot(t,y2);

>> axis([0,pi,-1,1])

>> subplot('position',[0.2,0.2,0.2,0.2]),plot(t,y12);

45.绘制图形的辅助操作

>> t=(0:15)*2*pi/15;

>> y=sin(t);

>> subplot(3,2,1),plot(t,y);title('Lins style is default')%默认

>> subplot(3,2,2),plot(t,y,'o');title('Lins style is o')%圆圈

>> subplot(3,2,3),plot(t,y,'k:');title('Lins style is k:')%黑虚线

>> subplot(3,2,4),plot(t,y,'k:*');title('Lins style is k:*')%黑虚线八线符

>> subplot(3,2,5),plot(t,y,'m-d');title('Lins style is m-d')%品红实线菱形符

>> subplot(3,2,6),plot(t,y,'r-p');title('Lins style is r-p')%红实线五角星符

相关推荐
Python大数据分析@20 小时前
Origin、MATLAB、Python 用于科研作图,哪个最好?
开发语言·python·matlab
牛马baby1 天前
MATLAB下载安装教程(附安装包)2025最新版(MATLAB R2024b)
开发语言·matlab
Evand J1 天前
【MATLAB例程】AOA与TDOA混合定位例程,适用于三维环境、4个锚点的情况,附下载链接
开发语言·matlab
m0_555762902 天前
Matlab 频谱分析 (Spectral Analysis)
开发语言·matlab
guygg882 天前
基于matlab的FIR滤波器
开发语言·算法·matlab
我爱C编程2 天前
基于拓扑结构检测的LDPC稀疏校验矩阵高阶环检测算法matlab仿真
算法·matlab·矩阵·ldpc·环检测
hie988943 天前
MATLAB锂离子电池伪二维(P2D)模型实现
人工智能·算法·matlab
88号技师3 天前
2025年6月一区-田忌赛马优化算法Tianji’s horse racing optimization-附Matlab免费代码
开发语言·算法·matlab·优化算法
m0_555762903 天前
matlab 教程
matlab
松果集3 天前
MATLAB基础知识【8】绘图,peaks,sphere,积分
matlab