⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zy19.m

📁 电路与系统专业的matlab程序。有很多经典的实例。
💻 M
字号:
% 二维绘图

clear all,echo on,hold off
Y=5*(rand(1,10)-0.5); 
pause,plot(Y) 
pause,plot(Y,'b','linewidth',2)
pause, title('my first plot'), xlabel('n'), ylabel('Y'),grid

 pause, t=0:0.5:4*pi;
y=exp(-0.1*t).*sin(t);  
pause,plot(t,y,'linewidth',2)

pause,y1=exp(-0.1*t).*sin(t+1); 
pause,plot(t,y1,'linewidth',2),

% 绘制多根曲线的方法

pause,plot(t,[y;y1],'linewidth',2),


% 用 hold 命令 
pause,plot(t,y,'linewidth',2), hold on 
pause,plot(t,y1,'g','linewidth',2),hold off

pause,figure(2)
pause,plot(t,y1,'b+','linewidth',2), hold on
t2=0:.2:2*pi;
y2=exp(-0.5*t2).*sin(5*t2+1);
pause,plot(t2,y2,':'),
pause,grid
hold off

% 用 plot(x1,y1,x2,y2,...)

pause,plot(t,y,'+g',t2,y2,'linewidth',2) ,
pause,plot(t,y,':r',t2,y2,':b','linewidth',2)
pause,title('线形,点型和颜色'),
pause,xlabel('时间'), ylabel('Y'),

% 用 plotyy(x1,y1,x2,y2)命令

pause,y3=5*y2; plotyy(t,y,t2,y3),grid 

%gtext('t,t2'),gtext('y'),gtext('y3')

% 其他坐标绘图

pause,subplot(2,2,1),stem(t,y), title('stem(t,y)')   %火柴杆图
pause,subplot(2,2,2),stairs(t,y),title('stairs(t,y)') % 阶梯图
pause,subplot(2,2,3),bar(t,y),title('bar(t,y)'),axis([0,20,-1,1])  % 条形图
pause,subplot(2,2,4),fill(t,y,'r'),title('fill(t,y,''r'')')   %实心图

% 复数绘图
z=exp((-.1+i)*t);
pause,subplot(2,2,1),plot(z),
title('复数绘图plot(z)')
pause,subplot(2,2,2),plot(t,z),
title('复数绘图plot(t,z)')
pause,subplot(2,2,3),polar(angle(z),abs(z)),
title('polar(angle(z),abs(z))')

z=0:0.1:2*pi;
x=sin(z);y=cos(z);
pause,subplot(1,2,1),plot(x,y),
pause,subplot(1,2,2),plot(x,y),
pause,axis('equal'),
pause,axis([-1, 1, -1, 1])
echo off

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -