u=@(t)(t>=0);
r=@(t)t.*(t>=0);
x=@(t)u(t)-u(t-4);
y=@(t)r(t+1)-2*r(t-1)+r(t-3);t=-10:1:10;thao=-10:1:10;h=zeros(1,length(t));i=1;
for it=t
   stem(thao,x(thao),'b-s')
   %axis([-7 7 -0.3 1.3])
   hold on
   stem(thao,y(it-thao),'k-o')
   %axis([-7 7 -0.3 1.3])
   h(i)=trapz(thao,x(thao).*y(it-thao));
   stem(t,h,'r-*')
   %axis([-7 7 -0.3 1.3])
   hold off
   pause()
   i=i+1;
 end

    