MATLAB: Designing IIR band-pass filter for signal with white noise

band passbutterworthchebyshevfilterfiltfiltiir

I am attempting to filter a signal (p1) that seems to be contaminated with white noise. I am trying to constuct either a Butterworth or Chebyshev filter for this issue, but my plots are always severly distorted, or not visible at all. I want to filter between 0.05 and 10Hz. Below is my code (simplified), but I feel like I must be missing a step.
Fn = fs/2;
Wp = [0.05 10]/Fn;
Rp = 1;
[b,a] = cheby1(8,Rp,Wp);
P1 = filtfilt(b,a,p1);
figure()
plot(T1,P1)

Best Answer

The filter is unstable, and that is the problem. You can see this if you look at the coefficients returned by cheby1 and analyse it first with the freqz function:
fs = 1000; % Guess — Not Supplied
Fn = fs/2;
Wp = [0.05 10]/Fn;
Rp = 1;
[b,a] = cheby1(8,Rp,Wp);
figure
freqz(b,a, 2^16, fs)
It is always best to use aero-pole-gain representation initially and then second-order-section realisation. Prorotype code that does this for an elliptic filter is:
Fs = 256000; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
Ws = [48 62]/Fn; % Stopband Frequency (Normalised)
Wp = [0.99 1.01].*Ws; % Passband Frequency (Normalised)
Rp = 1; % Passband Ripple
Rs = 90; % Passband Ripple (Attenuation)
[n,Wp] = ellipord(Wp,Ws,Rp,Rs); % Elliptic Order Calculation
[z,p,k] = ellip(n,Rp,Rs,Wp,'stop'); % Elliptic Filter Design: Zero-Pole-Gain
[sos,g] = zp2sos(z,p,k); % Second-Order Section For Stability
figure
freqz(sos, 2^20, Fs) % Filter Bode Plot
set(subplot(2,1,1), 'XLim',Wp*Fn.*[0.8 1.2]) % Optional

set(subplot(2,1,2), 'XLim',Wp*Fn.*[0.8 1.2]) % Optional
This creates a stable filter.
Note that frequency-selective filters will only work for band-limited noise. if the signal has broadband noise, wavelet denoising or other appropriate approaches will be required.
.