Butterworth bandpass filter on a signal using buttord and butter

23 次查看(过去 30 天)
Hi everyone.
I've been working on a butterworth bandpass filter on a signal, but I can't use the function buttord and butter properly together. The response frecuency of the signal I'm working with has been obtained using fft (shown in the image below). I want to make a bandpass filter between 5 and 450 Hz. Originally, I obtained my bandpass filter only using the function butter, but I select an arbitrary filter order and I need to obtain the order with the function buttord. The code I've been working with for the filter using buttord and butter is shown below the response frecuency image, but it didn't work properly. If someone could tell me what I'm doing wrong in the design of my Butterworth bandpass filter or if I'm designing it in a wrong way, I would be very thankful.
%Arbitrary values for the ripple in the passband and stopband
delta1=0.01;
delta2=0.005;
Ripplep=-20*log10(1-delta1); %Ripple in the passband
Ripples=-20*log10(delta2); %Ripple in the stopband
f=1260; %Sampling frecuency
fnyq=f/2; %Nyquist frecuency
wp=[10 450]/fnyq; %10 is the omegap frecuency for the inferior cut off frecuency portion. 450 is the omegap
%frecuency for the superior cut off frecuency portion
ws=[5 455]/fnyq; %5 is the omegas frecuency for the inferior cut off frecuency portion. 455 is the omegap
%frecuency for the superior cut off frecuency portion
[N,WN]=buttord(wp,ws,Ripplep,Ripples) %Obtain filter order and natural frecuency
[e,c]=butter(N,WN) %butterworth coeficients for the filter
bandpass_filt_data=filtfilt(e,c,window_data) %Apply filter to the original signal (window_data), which has
%a dimension of 15725X1

采纳的回答

Star Strider
Star Strider 2021-6-14
The transfer function implementation created an unstable filter.
Instead, use zero-pole-gain output from butter, then implement it as a second-order-section filter with zp2sos.
And always use freqz to assess the filter characteristics first. That will tell you if it met the design requirements.
Try this —
%Arbitrary values for the ripple in the passband and stopband
delta1=0.01;
delta2=0.005;
Ripplep=-20*log10(1-delta1); %Ripple in the passband
Ripples=-20*log10(delta2); %Ripple in the stopband
f=1260; %Sampling frecuency
fnyq=f/2; %Nyquist frecuency
wp=[10 450]/fnyq; %10 is the omegap frecuency for the inferior cut off frecuency portion. 450 is the omegap
%frecuency for the superior cut off frecuency portion
ws=[5 455]/fnyq; %5 is the omegas frecuency for the inferior cut off frecuency portion. 455 is the omegap
%frecuency for the superior cut off frecuency portion
[N,WN]=buttord(wp,ws,Ripplep,Ripples); %Obtain filter order and natural frecuency
[z,p,k]=butter(N,WN); %butterworth coeficients for the filter
[sos,g] = zp2sos(z,p,k);
figure
freqz(sos,2^14,f)
bandpass_filt_data=filtfilt(sos,g,window_data) %Apply filter to the original signal (window_data), which has
Unrecognized function or variable 'window_data'.
%a dimension of 15725X1
.
  2 个评论
José Santos Pérez Leal
Thank you very much, Star Strider, I will try to implement the zero-pole-gain to the filter design and then apply the filter to the signal. Thank you!!!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Digital Filter Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by