title: Convolution in matlab
body: <p>I'm trying to calculate this convolution:</p>
  
  <p>x[n] = δ[n+1] + δ[n] - δ[n-1]</p>
  
  <p>h[n] = (1/2)^n * u[n] . u[n] is the step function.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>&gt;&gt; n=[-10:10];
  &gt;&gt; x=zeros(1,length(n));
  &gt;&gt; x(n==-1)=1;
  &gt;&gt; x(n==0)=1;
  &gt;&gt; x(n==1)=-1;
  &gt;&gt; u=heaviside(n);
  &gt;&gt; h=(1/2).^n * u;
  ??? Error using ==&gt; mtimes
  Inner matrix dimensions must agree.
  </code></pre>
  
  <p>How do you exactly type my h[n]? What if it's u[n-1] instead?</p>