title: How do I plot the frequency response of a digital filter in MATLAB?
body: <p>I am trying to graph the frequency response. I was asked to use <code>filter</code> in MATLAB, but since I've read the manual, I still don't get how it performs a <code>Z</code> transform.</p>
  
  <p>I have the impulse response of the digital filter written below:</p>
  
  <pre><code>for i=1:22;
     y(i)= 0;
  end
  x(22) = 1;
  for k=23:2523
      x(k) = 0;
  end
  for n = 22:2522;
      y(n) = ((1/21)*x(n))+((20/21)*y(n-21));
  end
  plot(y);
  </code></pre>
  
  <p>It's just a feedback system of <code>y[n] = 1/21*x[n] + 20/21*y[n-21]</code></p>
  
  <p>Below are my calculations to compute the <code>Z</code> transform of the above system, which ultimately determines the impulse response:</p>
  
  <pre><code>Z(y) = Z((1/21)*x(n)+(20/21)*y(n-21))
  
  Y(Z) = (1/21)X(Z)+(20/21)*Z.^-21Y(Z)
  
  Z(Z)-(20/21)*Z.^-21Y(Z) = (1/21)X(Z)
  
  Y(Z)(1-(20/21)*Z.^-21) = (1/21)X(Z)  // divide by X(Z)*(1-(20/21)*Z.^-21)
  
  Y(Z)/X(Z) = (1/21)/(1-(20/21)*Z.^-21)
  
  H(Z) = (1/21)/(1-(20/21)*Z.^-21) // B = 1/21, A = 20/21
  
  H(Z) = (B*Z.^21)/(Z.^21-A)
  </code></pre>
  
  <p>How can I plot the frequency response of <code>H(Z)</code>?  Should I use <code>filter</code>?</p>