title: The deconv() function in MATLAB does not invert the conv() function
body: <p>I would like to convolve a time-series containing two spikes (call it Spike) with an exponential kernel (k) in MATLAB.  Call the convolved response "calcium1".  I would like to recover the original spike ("reconSpike") data using deconvolution with the kernel.  I am using the following code.</p>
  
  <pre><code>k1=zeros(1,5000);
  k1(1:1000)=(1.1.^((1:1000)/100)-(1.1^0.01))/((1.1^10)-1.1^0.01);
  k1(1001:5000)=exp(-((1001:5000)-1001)/1000);
  k1(1)=k1(2);
  
  spike = zeros(100000,1);
  spike(1000)=1;
  spike(1100)=1;
  
  calcium1=conv(k1, spike);
  reconSpike1=deconv(calcium1, k1);
  </code></pre>
  
  <p>The problem is that at the end of reconSpike, I get a chunk of very large, high amplitude waves that was not in the original data.  Anyone know why and how to fix it?</p>
  
  <p>Thanks!</p>