Analog Bessel filter output problem (nan)

6 views (last 30 days)
Amy Lg
Amy Lg on 8 Apr 2022
Commented: Amy Lg on 12 Apr 2022
I need to apply a normalized analog low pass bessel filter to my signal. I am not sure if my code is correct for analog filter. When I use below code, matlab gives Nan as the filtered signal. I appreciate any help to correct my code.
sig = MY SIGNAL;
sig_length = 5000001; % my signal length
fs = 10000e9 % sampling rate
fcut = 3e9; % cutoff frequency(GHz)
order = 4;
wo = 2*pi*fcut;
[z,p,k] = besself(order, wo,'low');
[num,den] = zp2tf(z,p,k); % Convert to transfer function form
filteredSignal = filtfilt(num,den, sig);

Answers (1)

Paul on 8 Apr 2022
The num and den inputs to filtfilt() are for a discrete-time filter. But besself() returns the numerator/denominator for a continuous-time filter.
If you want to filtfilt() the signal with the Bessel filter, you'll need to transform it to a discrete-time approximation using methods such as bilinear() or impinvar() in the Signal Processing Toolbox, or others avaialble in the Control System Toolbox. Keep in mind that the magnitude response with filtfilt() is the square of the magnitude response of the filter being used, so the magnitude of the discrete-time approximation is what's important.
If you want to do the forward/backward filtering with the continuous-time Bessel filter, I'm afraid you'll either have to write your own code or perhaps use Simulink to solve the ODE with sig as the input, then go in reverse. Of course you'll then have to decide on how the ODE solver is to compute values of the input signal between the samples in sig (assuming use of something higher than a first order solver). Also, filtfilt() takes some action to deal with transients that may have to be considered if writing your own code.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!