MATLAB在信号与系统中的应用(3)

1.阶跃函数的绘制几种图像的区别

t=0:0.01:3;
ft1=t.*(t>=0 & t<=1);
ft2=t.*(t>=0);
ft3=t.*(t>=0 & t<=1)+(t>=1);
ft4=(t-1).*(t>=1);
ft5=-(t-1).*(t>=0 & t<=1);
ft6=t.*(t>=2 & t<=3);
ft7=(t-2).*(t>=2 & t<=3);
>> subplot(241),plot(t,ft1),title('t[u(t)-u(t-1)]');
>> subplot(242),plot(t,ft2),title('tu(t-1)');
>> ft3=t.*(t>=0 & t<=1)+(t>1);
>> subplot(243),plot(t,ft3),title('t[u(t)-u(t-1)]+u(t-1)');
>> axis([0 6 0 2]);
>> subplot(244),plot(t,ft4),title('(t-1)u(t)');
>> axis([0 6 -1 2]);
>> subplot(245),plot(t,ft5),title('-(t-1)[u(t)-u(t-1)]');
>> subplot(246),plot(t,ft6),title('t[u(t-2)-u(t-3)]');
>> subplot(247),plot(t,ft7),title('(t-2)[u(t-2)-u(t-3)]');

实验图:
实验结果实验

2.使用MATLAB实现卷积

符号法求解卷积

syms tao;
>> t=sym('t','positive');
>> xt1=sym('heaviside(t)-heaviside(t-1)');
>> xt_tao=subs(xt1,t,tao)*subs(xt1,t,t-tao);
>> yt=int(xt_tao,tao,0,t);
>> yt=simplify(yt);
>> ezplot(yt,[0,2]);grid on

f(t)=u(t)-u(t-1),求s(t)=f(t)*f(t):
这里写图片描述

数值法求解卷积

t=0:dt:3;
f=(t>=1)-(t>=2);
f1=conv(f,f)*dt;
n=length(f1);
tt=(0:n-1)*dt+2;
subplot(121),plot(t,f),grid on
title('f(t)=u(t-1)-u(t-2)')
subplot(122),plot(tt,f1),grid on
title('s(t)=f(t)*f(t)')

这里写图片描述

dt=0.01;
t=-6:dt:6;
f1=(t>=-1)-(t>=1);
f2=(t==-5)+(t==5);
f3=(t==-1/2)+(t==1/2);
st1=conv(f1,f2);
st11=(t>=-6)-(t>=-4)+(t>=4)-(t>=6);
st2=conv(stt,f2);
st=(t>=-5)-(t>=-4)+(t>=4)-(t>=5);
st3=conv(st,f2);
st4=conv(f1,f3);
n1=length(st1);
n2=length(st2);
n3=length(st3);
n4=length(st4);
t1=(0:n1-1)*dt-12;
t2=(0:n2-1)*dt-12;
t3=(0:n3-1)*dt-12;
t4=(0:n4-1)*dt-12;
subplot(221),plot(t1,st1),axis([-7 7 0 3]),title('s(t)=f1(t)*f2(t)')
subplot(222),plot(t2,st2),axis([-12 12 0 3]),title('s(t)=f1(t)*f2(t)*f2(t)')
subplot(223),plot(t3,st3),axis([-12 12 0 3]),title('s(t)=f(t)*f(t)')
subplot(224),plot(t4,st4),axis([-1 1 0 3]),title('s(t)=f1(t)*f3(t)')

结果

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小刘同学要加油呀

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值