%exam_8_21 
clear;
dt=0.01;t1=0:dt:4;
h1=2*exp(-t1)-exp(-2*t1);
t2=-4:dt:6;
f1=ones(1,length(t2));
yzs_1=conv(f1,h1);                   
yzs_1=yzs_1*dt;                        
ts=min(t1)+min(t2);
te=max(t1)+max(t2);
t=ts:dt:te;
% figure(1);
subplot(2,4,1);
plot(t1,h1);grid on;
axis([min(t1),max(t1),min(h1)-abs(min(h1)*0.2),max(h1)+abs(max(h1)*0.2)])
title('h(t)','Fontsize',20);xlabel('t','Fontsize',20);
set(gca,'Fontsize',20);
subplot(2,4,2);
plot(t2,f1);grid on;
axis([min(t2),max(t2),min(f1)-abs(min(f1)*0.2),max(f1)+abs(max(f1)*0.2)])
title('f(t)','Fontsize',20);xlabel('t','Fontsize',20);
set(gca,'Fontsize',20);
subplot(2,2,3)
plot(t,yzs_1);grid on;
axis([min(t),max(t),min(yzs_1)-abs(min(yzs_1)*0.2),max(yzs_1)+abs(max(yzs_1)*0.2)])
title('连续LTI系统的零状态响应yzs(t)','Fontsize',20);xlabel('t','Fontsize',20);
set(gca,'Fontsize',20);

n1=0:20;
h2=0.5.^n1;
n2=-4:6;
f2=ones(1,length(n2));
yzs_2=conv(f2,h2);                                          
ns=min(n1)+min(n2);
ne=max(n1)+max(n2);
n=ns:ne;
% figure(2);
subplot(2,4,3)
stem(n1,h2);grid on;
axis([min(n1),max(n1),min(h2)-abs(min(h2)*0.2),max(h2)+abs(max(h2)*0.2)])
title('h(n)','Fontsize',20);xlabel('n','Fontsize',20);
set(gca,'Fontsize',20);
subplot(2,4,4)
stem(n2,f2);grid on;
axis([min(n2),max(n2),min(f2)-abs(min(f2)*0.2),max(f2)+abs(max(f2)*0.2)])
title('f(n)','Fontsize',20);xlabel('n','Fontsize',20);
set(gca,'Fontsize',20);
subplot(2,2,4)
stem(n,yzs_2);grid on;
axis([min(n),max(n),min(yzs_2)-abs(min(yzs_2)*0.2),max(yzs_2)+abs(max(yzs_2)*0.2)])
title('离散LTI系统的零状态响应yzs(n)','Fontsize',20);xlabel('n','Fontsize',20);
set(gca,'Fontsize',20);
