0
$\begingroup$

Suppose I have an IIR filter in the $z$-domain in the following form: $$ H\left(z\right)=\frac{1}{1-0.2z^{-1}-0.1z^{-2}} $$

How do I represent this in MATLAB?

I am pretty sure if I just listed the coefficients as H = [1 -0.2 -0.1]; this would be considered wrong. Can somebody help me with this please?

$\endgroup$
1
$\begingroup$

MATLAB assumes that the transfer function has a form like this:

$$ H(z) = \frac{b_0 + b_1z^{-1} + \ ... \ + b_{M}z^{-M}}{1+a_1z^{-1}+ \ ... \ + a_{N}z^{-N}} $$

So then you can read off the coefficients from your equation as $b_0=1$, $a_0=1$ (always assumed), $a_1 = -0.2$, and $a_2 = -0.1$. In MATLAB world, you define the coefficients as:

b = 1;
a = [1; -0.2; -0.1];

Further, if you wanted to actually use the filter on some signal, you can call the in-built function:

filterOutput = filter(b, a, filterInput);
$\endgroup$
5
  • 1
    $\begingroup$ That filter command wouldn't give the correct output. It should be filter(b,a,x). $\endgroup$ – Matt L. Dec 2 '20 at 12:38
  • $\begingroup$ But i don't have x in the first place, nor its part of the question $\endgroup$ – Raykh Dec 2 '20 at 21:33
  • $\begingroup$ @MattL thanks I fixed that $\endgroup$ – Engineer Dec 2 '20 at 21:42
  • $\begingroup$ @Raykh I guess I assumed you wanted to use the filter, but maybe you meant something else. When you say "How do I represent this in MATLAB?", what do you mean? Do you want to plot the transfer function, look at the pole-zero diagram, or maybe something else? $\endgroup$ – Engineer Dec 2 '20 at 21:44
  • $\begingroup$ I think I can take it from here. Thank you very much for your help $\endgroup$ – Raykh Dec 2 '20 at 22:40
1
$\begingroup$

You have to define numerator and denominator polynomials. In your case you have

b = 1;
a = [1,-0.2, -0.1];
$\endgroup$
3
  • $\begingroup$ But what's to it from here? Do you do H = b/a? $\endgroup$ – Raykh Dec 2 '20 at 21:32
  • $\begingroup$ @Raykh: The coefficient vectors a and b completely represent your filter. That was your question. You have to tell us what else you want to do. $\endgroup$ – Matt L. Dec 2 '20 at 21:37
  • $\begingroup$ No worries, thank you very much for your help $\endgroup$ – Raykh Dec 2 '20 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.