Troubles with Butterworth Bandpass filter
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Marco Gaetani d'Aragona
el 20 de Mayo de 2020
Respondida: Seong Jun Ha
el 20 de Oct. de 2021
Hi to everyone,
I'm experiencing some problems when trying to apply a Butterworth Bandpass filter in Matlab. In particular, I want to filter an acceleration history recorded at the base of a building. The sampling frequency is 1000Hz, and i want to preserve the signal between 0.1Hz and 27Hz.
I adopted two different ways to code the Butterworth filter in Matlab, but I'm not able to obtain the same response that I obtain adopting the professional software seismosignal. In particular, the problem is with the response obtained by double integration of filitered accelerogram. Here the code I used (the .txt is attached)
%load accelerations (m/s^2)
Acc=load('Acceleration.txt');
%time step
dt=0.001;
% Frequency corresponding to sampling of 0.001s for each acceleration value
Fsp=1/dt;
% set Bandpass frequencies
Fcp_low=0.1; %lower cutoff frequency
Fcp_high=27; %higher cutoff frequency
%version 1
[z,p,k]=butter(4,[Fcp_low Fcp_high]/(Fsp/2),'bandpass');
[sos,g]=zp2sos(z,p,k);
udd_cor=filtfilt(sos,g,Acc);
ud_cor=cumtrapz(udd_cor)*dt;
u_cor=cumtrapz(ud_cor)*dt;
% version 2
[b,a]=butter(4,[Fcp_low Fcp_high]/(Fsp/2));
udd_cor1=filter(b,a,Acc);
ud_cor1=cumtrapz(udd_cor1)*dt;
u_cor1=cumtrapz(ud_cor1)*dt;
This is the displacement response obtained with seismosignal:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/295743/image.jpeg)
This is the response obtained adopting "version 1" of Butterworth filter:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/295793/image.jpeg)
This is the response obtained adopting "version 2" of Butterworth filter:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/295798/image.jpeg)
Probably I'm doing something wrong.
Every help would be very glad.
Thank you in advance
0 comentarios
Respuestas (2)
Star Strider
el 20 de Mayo de 2020
My expertise in this area stops with the filters and thier implementations.
An appropriate time vector:
Fs = 1000;
L = numel(Acc);
t = linspace(0, L-1, L)/Fs;
Only the ‘version 1’ code designs and implements an appropriate, stable filter. (The filter in ‘version 2’ is unstable, and using filter instead of filtfilt is not advisable.)
Since I have no idea how to interpret the double integration of the same vector (instead of over different variables or with respect to cumtrapz, different dimensions of the same matrix), I will leave that discussion to those who do.
0 comentarios
Seong Jun Ha
el 20 de Oct. de 2021
I experienced the same problem. Adding zero pad was the answer. I hope that your problem was already solved.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!