一、实验内容
(1)仔细阅读并验证执行程序示例
a = [1 4 4];
b = [1 3];
sys = tf(b, a);
td = 0.01;
t = 0 : td : 10;
f = exp(-t);
y = lsim(sys, f, t);
y1 = impulse(sys, t) ;
y2 = step(sys, t);
subplot(3,1,1)
plot(t, y,'r'); title('零状态响应');
subplot(3,1,2)
plot(t,y1,'b'); title('冲激响应');
subplot(3,1,3)
plot(t,y2,'g'); title('阶跃响应');
%三种响应的曲线分别用红、蓝、绿、色表示)
xlabel('t(sec)');
ylabel('y(t)');
grid on
syms T t tao
ut=exp(-t);
ht=exp(-t/T)/T;
uh_tao=subs(ut,t,tao)*subs(ht,t,t-tao);
yt=simplify(simplify(int(uh_tao,tao,0,t)))
syms tao
t=sym('t','positive');
ut=heaviside(t)-heaviside(t-1);
ht=t*exp(-t);
yt=int(subs(ut,t,tao)*subs(ht,t,t-tao),tao,0,t)
subplot(3,1,1),ezplot(ut,[0,6])
subplot(3,1,2),ezplot(ht,[0,6])
subplot(3,1,3),ezplot(yt,[0,6])
a=[1 2 2];
b=[1];
t=0:0.01:10;
sys=tf(b,a);
ft=heaviside(t);
yt=lsim(sys,ft,t);
yt1=impulse(sys,t);
yt2=step(sys,t);
subplot(3,1,1)
plot(t,yt,'r');title('零状态响应');
subplot(3,1,2)
plot(t,yt1,'b');title('冲激响应');
subplot(3,1,3)
plot(t,yt2,'g');title('阶跃响应');
xlabel('t(sec)');
ylabel('y(t)');
grid on
t=-3:0.01:3;
T1=2;
T2=4;
ft1=2*rectpuls(t,T1);
ft2=rectpuls(t,T2)
subplot(2,1,1)
plot(t,ft1);
subplot(2,1,2)
plot(t,ft2)
grid on;
syms tao
t=sym('t','positive');
ft1=2*heaviside(t+1)-2*heaviside(t-1);
ft2=heaviside(t+2)-heaviside(t-2);
ft_tao=subs(ft1,t,tao)*subs(ft2,t,t-tao);
yt=int(ft_tao,tao,0,t);
yt=simplify(yt);
subplot(3,1,1),ezplot(ft1,[0,6])
subplot(3,1,2),ezplot(ft2,[0,6])
subplot(3,1,3),ezplot(yt,[0,6])
grid on