2
$\begingroup$

I don't unstand the nature of the output in Matlab's "butter" command. Calling

[b,a] = butter(4, 0.5, 'low');

gives me two vectors, which the documentation says are b for numerator, and a for denominator, of the transfer function.

However plotting the frequency response of this transfer function with freqz() does not give me what I expected.

If I plot

freqz(b./a)

I see:

freqz of b over a

This is not a low pass filter, this is some sort of band stop filter suppressing the middle frequencies. However if I plot

freqz(b)

I see what looks like the low pass filter I was hoping for:

freqz of b only

So if I want to use a Butterworth filter to low pass my data, do I only use b? And if so what is the point of a?

$\endgroup$
  • 1
    $\begingroup$ Correct: freqz(b,a), i.e., you should supply both the numerator and denominator to freqz. $\endgroup$ – Oscar Mar 9 '15 at 12:18
4
$\begingroup$

You are using wrong syntax. You should call freqz function as:

freqz(b,a)

You do not divide any coefficients. In case of non-recursive filters (FIR) you use only coefficients stored in b vector. When you are using the recursive LCCDE (Linear Constant Coefficients Difference Equation) (mostly IIR filters) then you need also the a vector. I suggest you to set a to 1 if you use non-recursive FIR filters.

You should also watch out for numerical problems with transfer function representation as mentioned in final paragraph of this manual entry and this answer. It's always safer to use z-p-k representation.

$\endgroup$
  • $\begingroup$ That is: RTGM!!! $\endgroup$ – Peter K. Mar 9 '15 at 12:34
  • 1
    $\begingroup$ I always say: if you want to learn MATLAB, there is no better source than F1. They have the best manual ever. $\endgroup$ – jojek Mar 9 '15 at 12:36
  • $\begingroup$ Blimey, I wasn't doing my division in the Fourier domain. Now I see why that doesn't work! $\endgroup$ – barnhillec Mar 10 '15 at 10:01

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.