%
%  convolution problems for homework 4
%
  t1 = [-2:0.001:2];
  t2 = [-2:0.001:4];
%
  x1 = @(t) 0*(t<-1)+1*((t>=-1)&(t<=1))+0*(t>1);
  x2 = @(t) 0*(t<-0.5)+1*((t>=-0.5)&(t<=2.5))+0*(t>2.5)
%  
  [y,ty] = convolve(t1,t2,x1(t1),x2(t2));
%  
  figure;
  orient tall
  subplot(3,1,1); plot(t1,x1(t1),'Linewidth',3); grid; ylabel('x_1(t)'); 
  subplot(3,1,2); plot(t2,x2(t2),'Linewidth',3); grid; ylabel('x_2(t)'); 
  subplot(3,1,3); plot(ty,y,'Linewidth',3);grid; axis('tight');xlabel('Time (sec)'); ylabel('y(t)');
