%
%  convolution problems for homework 5
%
   tx = [-1:0.001:8]; % time from -1 to 8 with an increment of 0.001 seconds
   th = [-1:0.001:8];
%
   h = @(t) 0*(t<0)+exp(-t).*(t>=0);
   T = 1.5;
   x = @(t) 0*(t<T)+exp(-(t-T)).*(t>=T)
   y_true = @(t) 0*(t<T)+exp(-t).*exp(T).*(t-T).*(t>=T);
%  
  [y,ty] = convolve(tx,th,x(tx),h(th));
%  
  figure;
  orient tall
  subplot(3,1,1); plot(tx,x(tx),'Linewidth',3); grid; ylabel('x(t)'); 
  subplot(3,1,2); plot(th,h(th),'Linewidth',3); grid; ylabel('h(t)'); 
  subplot(3,1,3); 
  hold on
  plot(ty,y,'r','Linewidth',1.5);
  plot(ty,y_true(ty),'b--');
  hold off
  grid; axis('tight');xlabel('Time (sec)'); ylabel('y(t)');
