필터 지우기
필터 지우기

Troubles with Butterworth Bandpass filter

조회 수: 3 (최근 30일)
Marco Gaetani d'Aragona
Marco Gaetani d'Aragona 2020년 5월 20일
답변: Seong Jun Ha 2021년 10월 20일
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:
This is the response obtained adopting "version 1" of Butterworth filter:
This is the response obtained adopting "version 2" of Butterworth filter:
Probably I'm doing something wrong.
Every help would be very glad.
Thank you in advance

답변 (2개)

Star Strider
Star Strider 2020년 5월 20일
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.

Seong Jun Ha
Seong Jun Ha 2021년 10월 20일
I experienced the same problem. Adding zero pad was the answer. I hope that your problem was already solved.

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by