3

I've been searching all over but I can't seem to understand the following example provided on here back in 2009.

I'm trying to implement a simple low pass filter to a set of data in Matlab and this is the following example I was referred to here on SO. Link to example

xfilt = filter(a, [1 a-1], x);

where a = T/τ, T = the time between samples, and τ (tau) is the filter time constant.

Now the coefficients are what are giving me the most trouble. Based off of the first order Laplace transfer function being the following:

(1/Ts) / (1 + (1/Ts)) where (1/Ts) = a

It would be great to know how the denominator coefficients were found for the function above.

alpereira7
  • 1,522
  • 3
  • 17
  • 30
Cory
  • 51
  • 1
  • 6

1 Answers1

2

According to the filter documentation, the first argument is Numerator coefficients of rational transfer function, let's call them [b0 b1 b2 ...] and the second argument is Denominator coefficients of rational transfer function, let's call them [a0 a1 a2].

Since you want a single-pole low pass filter, the time domain equation is:

A0*y(n) = B0*x(n) - A1*y(n-1);

You can simplify the above equation making a0 = 1;, b0 = B0/A0 and a1 = A1/A0;

y(n) = b0*x(n) - a1*y(n-1);

For stability reasons and if you want no change of gain, you will fix b0 - a1 = 1;

y(n) = b0*x(n) - (b0-1)*y(n-1);

The equivalent transfer function is

H(z) = b0 / (1 + (b0-1)*z^-1);

So the numerator coefficient is b0 and the denominator coefficients are 1 and b0-1. Hence the writing of xfilt = filter(b0, [1 b0-1], x);

If fc is the frequency cut and Fs the frequency sample, b0 = 2*pi*fc/Fs.

alpereira7
  • 1,522
  • 3
  • 17
  • 30