MATLAB1常见信号的MATLAB表示及运算.docx
《MATLAB1常见信号的MATLAB表示及运算.docx》由会员分享,可在线阅读,更多相关《MATLAB1常见信号的MATLAB表示及运算.docx(17页珍藏版)》请在冰豆网上搜索。
MATLAB1常见信号的MATLAB表示及运算
1、用MATLAB命令函数分别绘出抽样信号、矩形脉冲信号、周期矩形脉冲信号、三角波脉冲信号、三角波周期信号的波形,理解其中参数的意义。
t=-20:
0.01:
20;
f10=sinc(t);
f20=rectpuls(t,2);
f30=square(t,2);
f40=tripuls(t,0.5);
f50=sawtooth(t,0.5);
subplot(5,1,1);
plot(t,f10);
axis([-10,10,-2,2]);
subplot(5,1,2);
plot(t,f20);
axis([-10,10,-2,2]);
subplot(5,1,3);
plot(t,f30);
axis([-10,10,-2,2]);
subplot(5,1,4);
plot(t,f40);
axis([-10,10,-2,2]);
subplot(5,1,5);
plot(t,f50);
axis([-10,10,-2,2]);
t=-20:
0.01:
20;
f20=rectpuls(t,2);
f21=rectpuls(t,4);
f22=rectpuls(t,8);
f23=rectpuls(t,16);
f24=rectpuls(t,32);
subplot(5,1,1);
plot(t,f20);
axis([-10,10,-2,2]);
subplot(5,1,2);
plot(t,f21);
axis([-10,10,-2,2]);
subplot(5,1,3);
plot(t,f22);
axis([-10,10,-2,2]);
subplot(5,1,4);
plot(t,f23);
axis([-10,10,-2,2]);
subplot(5,1,5);
plot(t,f24);
axis([-18,18,-2,2]);
m=5/pi;
t=-20:
0.0001:
20;
f30=square(t,4*pi);
f31=square(t,8*pi);
f32=square(t,16*pi);
f33=square(m*t,25);
f34=square(m*t,50);
subplot(5,1,1);
plot(t,f30);
axis([-10,10,-2,2]);
subplot(5,1,2);
plot(t,f31);
axis([-10,10,-2,2]);
subplot(5,1,3);
plot(t,f32);
axis([-10,10,-2,2]);
subplot(5,1,4);
plot(t,f33);
axis([-10,10,-2,2]);
subplot(5,1,5);
plot(t,f34);
axis([-10,10,-2,2]);
t=-20:
0.01:
20;
f40=tripuls(t,2);
f41=tripuls(t,4);
f42=tripuls(t,8);
f43=tripuls(t,16);
f44=tripuls(t,32);
subplot(5,1,1);
plot(t,f40);
axis([-10,10,-2,2]);
subplot(5,1,2);
plot(t,f41);
axis([-10,10,-2,2]);
subplot(5,1,3);
plot(t,f42);
axis([-10,10,-2,2]);
subplot(5,1,4);
plot(t,f43);
axis([-10,10,-2,2]);
subplot(5,1,5);
plot(t,f44);
axis([-18,18,-2,2]);
m=5/pi;
t=-20:
0.0001:
20;
f50=sawtooth(t,0.25);
f51=sawtooth(t,0.5);
f52=sawtooth(t,0.75);
f53=sawtooth(m*t,0.25);
f54=sawtooth(m*t,0.75);
subplot(5,1,1);
plot(t,f50);
axis([-10,10,-2,2]);
subplot(5,1,2);
plot(t,f51);
axis([-10,10,-2,2]);
subplot(5,1,3);
plot(t,f52);
axis([-10,10,-2,2]);
subplot(5,1,4);
plot(t,f53);
axis([-10,10,-2,2]);
subplot(5,1,5);
plot(t,f54);
axis([-10,10,-2,2]);
2、分别用MATLAB的数值运算和符号运算功能,绘出下列连续时间信号的波形。
ﻫ
symst;
f=sym('(2-exp(-2*t))*heaviside(t)');
ezplot(f,[-1,10]);
t=-1:
0.01:
10;
t1=-1:
0.01:
-0.01;
t2=0:
0.01:
10;
f1=[zeros(1,length(t1)),ones(1,length(t2))];
f=(cos(pi*t/2))*f1;
plot(t,f)
axis([-1,10,0,2.1])
sym t;
f=sym('cos(pi*t/2)*(heaviside(t)-heaviside(t-4))');
ezplot(f,[-2,10]);
t=-1:
0.01:
10;
f1=stepfun(t,0)-stepfun(t,4);
f=(cos(pi/2*t)).*f1;
plot(t,f)
axis([-2,10,-1.1,1.1]);
symt;
f=sym('exp(t)*cos(t)*heaviside(t)');
ezplot(f,[-2,10]);
t=-2:
0.01:
10;
f1=stepfun(t,0);
f=(exp(t).*cos(t)).*f1;
plot(t,f)
axis([-2,10,-7000,1100]);
symt;
f=sym('2/3*t*heaviside(t+2)');
ezplot(f,[-10,10]);
t=-10:
0.001:
10;
f1=stepfun(t,-2);
f=2/3.*t.*f1;
plot(t,f);
axis([-10,10,-2,7]);
3、已知信号的波形如右图所示,绘出满足下列要求的信号波形。
1
syms ty;
f=sym('2*heaviside(t)-heaviside(t-1)-heaviside(t-2)');
f1=subs(f,t,-t);
subplot(2,1,1);
ezplot(f,[-3,3]);
subplot(2,1,2);
ezplot(f1,[-3,3]);
2
ymsty;
f=sym('2*heaviside(t)-heaviside(t-1)-heaviside(t-2)');
f1=subs(f,t,t-2);
subplot(2,1,1);
ezplot(f,[-3,6]);
subplot(2,1,2);
ezplot(f1,[-3,6]);
3
symst y;
f=sym('2*heaviside(t)-heaviside(t-1)-heaviside(t-2)');
f1=subs(f,t,0.5*t);
f2=subs(f,t,2*t);
subplot(3,1,1);
ezplot(f,[-3,6]);
title('f(t)');
subplot(3,1,2);
ezplot(f1,[-3,6]);
title('f(0.5t)');
subplot(3,1,3);
ezplot(f2,[-3,6]);
title('f(2t)');
4
symsty;
f=sym('2*heaviside(t)-heaviside(t-1)-heaviside(t-2)');
f1=subs(f,t,(0.5*t)+1);
subplot(2,1,1);
ezplot(f,[-3,3]);
title('f(t)');
subplot(2,1,2);
ezplot(f1,[-3,3]);
title('f(0.5t+1)');
4、利用MATLAB画出复信号的实部、虚部、模和辅角。
clear
t=-10:
0.001:
10;
f=2*exp(j*(t+pi/4));
t_real=real(f);
t_imag=imag(f);
t_range= abs(f);
t_angle=angle(f);
subplot(2,2,1);
plot(t,t_real);
title('real');
gridon;
subplot(2,2,2);
plot(t,t_imag)
title('imag');
gridon;
subplot(2,2,3);
plot(t,t_range);
title('rang');
gridon;
subplot(2,2,4);
plot(t,t_angle);
title('angle');
gridon;