信号与系统MATLAB实验(教师版)

发布时间 : 星期二 文章信号与系统MATLAB实验(教师版)更新完毕开始阅读

f=(t>0);

保存,文件名是Heaviside ,调用该函数即可画图,例 t=-1:0.01:3; f=heaviside(t); plot(t,f)

axis([-1,3,-0.2,1.2]) 或者

y=sym('Heaviside(t)'); ezplot(y,[-1,5]);grid on

2. 信号基本运算的MATLAB实现

信号基本运算是乘法、加法、尺度、反转、平移、微分、积分,实现方法有数值法和符号法

例1-11 以f(t)为三角信号为例,求f(2t) , f(2-2t)

t=-3:0.001:3;

ft=tripuls(t,4,0.5);

subplot(3,1,1); plot(t,ft); grid on; title ('f(t)');

ft1= tripuls(2*t,4,0.5);

subplot(3,1,2); plot(t,ft1); grid on; title ('f(2t)');

ft2= tripuls(2-2*t,4,0.5);

subplot(3,1,3); plot(t,ft2); grid on; title ('f(2-2t)');

例1-12 已知f1(t)=sinwt , f2(t)=sin8wt , w=2pi , 求f1(t)+f2(t)和f1(t)f2(t) 的波形图 w=2*pi;

t=0:0.01:3; f1=sin(w*t); f2=sin(8*w*t); subplot(211)

plot(t,f1+1,':',t,f1-1,':',t,f1+f2) grid on,title('f1(t)+f2(t))') subplot(212)

plot(t,f1,':',t,-f1,':',t,f1.*f2) grid on,title('f1(t)*f2(t)')

符号算法也可实现上述运算,以信号的微积分运算为例说明符号算法应用 微分的调用格式为 diff(function,’variable’,n) 积分的调用格式为 int(function,’variable’,a,b)

5

式中function表示要微分或积分的函数,variable表示运算变量,n表示求导阶数,默认值是求一阶导数,a是积分下限,b是积分上限,a b默认是求不定积分。 例1-13 求一阶导数的例题,已知y1?sin(ax2),y2?xsinxlnx clear

syms a x y1 y2 %定义符号变量a, x ,y1, y2 y1=sin(a*x^2); %符号函数y1 y2=x*sin(x)*log(x); %符号函数y2

dy1=diff(y1,’x’) %无分号直接显示结果 dy2=diff(y2) %无分号直接显示结果

1xxex例1-14 求积分的例题,?(x?ax?)dx,?dx 202(1?x)5 clear

syms a x y3 y4

y3=x^5-a*x^2+sqrt(x)/2; y4=(x*exp(x))/(1+x)^2; iy3=int(y3,'x') iy4=int(y4,0,1) 三、上机实验内容 1. 验证实验原理中程序 2. 画出信号波形

(1)f(t)?(2?e解: t=0:0.001:15; f1=(2-exp(-2*t)); f2=(t>=0); f3=f1.*f2; plot(t,f3)

?2t)u(t)

6

(2)f(t)?(1?cos?t)[u(t)?u(t?2)] 解: t=-2:0.01:5; f1=1+cos(pi*t); f2=(t>=0)-(t>=2); ft=f1.*f2; plot(t,ft);

7

3.信号f(t)?(2?e?2t)u(t),求f(2t)、f(2?t)波形

3解:

syms t;

ft=heaviside(t); f1=(2-exp(-2*t))*ft; subplot(3,1,1);

ezplot(f1,[-2*pi,2*pi]); grid on; title ('f(t)'); f2=subs(f1,t,2*t); subplot(3,1,2);

ezplot(f2,[-2*pi,2*pi]); grid on;

title ('f(2t)'); f3=subs(f1,t,2-t);

8

联系合同范文客服:xxxxx#qq.com(#替换为@)