# Zeros on [b,a] output of butter filter

20 views (last 30 days)
Shaula Garibbo on 20 Jan 2020
Commented: Star Strider on 21 Jan 2020 at 16:10
Hi. I'm trying to create a low-pass filter for a large collection of audio files to make some room on my hard drives. I'm using the butter filter as follows:
fn = fs/2; %(fs = 32000)
fc = 125/fn; %normalised passband frequency = 0.0078
fz = 135/fn; %normalised stopband frequency = 0.0084
[n, wn] = buttord(fc,fz,3,60); %(n = 60, wn = 0.0078)
[b,a] = butter(n, wn, ftype);
But the 'b' output component is always made up of zeros (I just get blank graphs on the freqz plots).
I suspect I have misunderstood something along the line, but I am overall aiming for a filter that reads in the 32kHz audio file, and removes all frequencies over 125Hz, as I do not need them for my analysis. Any advice would be greatly appreciated.

Star Strider on 20 Jan 2020
The filter is unstable. This can easily be remedied by converting to zero-pole-gain realization, and then second-order section implementation:
ftype = 'low';
fs = 32000
fn = fs/2; %(fs = 32000)
fc = 125/fn; %normalised passband frequency = 0.0078
fz = 135/fn; %normalised stopband frequency = 0.0084
[n, wn] = buttord(fc,fz,3,60); %(n = 60, wn = 0.0078)
[z,p,k] = butter(n, wn, ftype); % Use Zero-Pole-Gain Representation
[sos,g] = zp2sos(z,p,k); % Second-Order Section For Stability
figure
freqz(sos, 2^14, fs) % Filter Bode Plot
Then use:
signal_filtered = filtfilt(sos,g,signal);
to do the actual filtering.

Star Strider on 21 Jan 2020 at 12:48
Use windowing with FIR filters, not IIR filters. The fir1 function does this, my favourite approach being the kaiserord function.
Getting acceptable results from FIR filters requires long filters, and those are by definition less efficient. The most efficient filter with respect to computation time is the elliptical design. (Like the Butterworth design, it is an IIR filter.) See the documentation on ellipord and ellip for those, since the syntax differs slightly from the Butterworth filter functions.
Shaula Garibbo on 21 Jan 2020 at 15:53
Thank you! Being pointed in the right direction is incredibly useful.
Star Strider on 21 Jan 2020 at 16:10
As always, my pleasure!