clf
clear all
set(0,'defaultaxesfontsize',20);
t=0:.01:14;
%
%h=rect(0.5*(t-1))-rect(0.5*(t-5))+100*rect((1/.01)*(t-7));
%x=t.*rect((1/6)*(t-3))
%+2*rect(t-2.5)-3*rect(0.5*(t-4))+(t-8).*rect((t-6.5)/3);
%
%h=rect(0.5*(t-1));
h=rect(t-0.5);
x=t.*rect(0.5*(t-1))+(t-4).*rect(0.5*(t-3))+(t-4).*rect(0.5*(t-5))+(t-8).*rect(0.5*(t-7));
%x=t.*rect(0.5*(t-1))+2*rect(t-2.5)-3*rect(0.5*(t-4))+(t-8).*rect((t-6.5)/3);
%x=t.*rect(t-0.5)-(t-2).*rect(t-1.5);
%x=2*rect(t-0.5)-(t-3).*rect(0.25*(t-3))-2*rect(t-5.5);
y=0.01*conv(x,h);
%
x1=t.*rect(0.5*(t-1));
x2=-(t-2).*rect(0.5*(t-1));
y1=0.01*conv(x1,rect(t-0.5));
y2=-0.01*conv(x2,rect(t-2.5));
y3=0.01*conv(x1,rect(t-4.5));
y4=-0.01*conv(x2,rect(t-6.5));
ysum=y1+y2+y3+y4;
norm(y-ysum)
%
e1=-3; e2=3;
subplot(2,2,1)
plot(t,x,'Linewidth',3)
grid
axis([min(t) max(t) e1 e2])
set(gca,'XTick',[min(t):max(t)],'YTick',[e1:0.5:e2])
title('x(t)');
subplot(2,2,2)
plot(t,h,'Linewidth',3)
grid
axis([min(t) max(t) e1 e2])
set(gca,'XTick',[min(t):max(t)],'YTick',[e1:0.5:e2])
title('h(t)');
subplot(2,2,3)
plot([t t(1:end-1)],y,'Linewidth',3)
grid
axis([min(t) max(t) e1 e2])
set(gca,'XTick',[min(t):max(t)],'YTick',[e1:0.5:e2])
title('y(t)=x(t)*h(t)');
subplot(2,2,4)
plot(t,x,'Linewidth',3)
grid
axis([min(t) max(t) e1 e2])
set(gca,'XTick',[min(t):max(t)],'YTick',[e1:0.5:e2])
title('x(t)');
