# Simple Filter representation in Matlab

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?

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);

• That filter command wouldn't give the correct output. It should be filter(b,a,x). Commented Dec 2, 2020 at 12:38
• But i don't have x in the first place, nor its part of the question Commented Dec 2, 2020 at 21:33
• @MattL thanks I fixed that Commented Dec 2, 2020 at 21:42
• @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? Commented Dec 2, 2020 at 21:44
• I think I can take it from here. Thank you very much for your help Commented Dec 2, 2020 at 22:40

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

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

• But what's to it from here? Do you do H = b/a? Commented Dec 2, 2020 at 21:32
• @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. Commented Dec 2, 2020 at 21:37
• No worries, thank you very much for your help Commented Dec 2, 2020 at 22:39