MATLAB: Butter bandpass filter – why the Wp 0.4 doesn´t works and 0.6 does

acelerometer signalbutterfilterwp

I am analyzing an acelerometer data signal. I have to apply a bandpass Butterworth filter with a Wp value (low frequency pass) of 0.4 hz.
I paste the matlab code.
dat=load('imput_data.txt');
orden=4;
f=[0.4/500 10/500];
%f=[0.6/500 10/500];
[b,a]=butter(orden,f,'bandpass');
result(:,1)=filter(b,a,dat(:,1));
I do not really know why the filter does not work for a wp=0.4 and it does for wp=0.6.

Best Answer

Thank so much for your comments, I have prepared a matlab code where you can see what i am taking about. I have used a sino signal.
Try it and tell me what do you think about.
clear clc tic
% Signal sino and filters
% Time(s), frequence (Hz) tf=10; f=0.6; a=1; muestreo=1000;
t=[0:1/muestreo:tf]'; y=a*sin(2*pi*f*t);
% Filter orden 4 from 0.4 to 10 Hz orden=4; f=[0.4/500 10/500]; [b,a]=butter(orden,f,'bandpass'); resultados(:,1)=filter(b,a,y);
% Filter orden 4 from 0.6 to 10 Hz orden=4; f=[0.6/500 10/500]; [b,a]=butter(orden,f,'bandpass'); resultados(:,2)=filter(b,a,y);
% Filter orden 4 from 0.8 to 10 Hz orden=4; f=[0.8/500 10/500]; [b,a]=butter(orden,f,'bandpass'); resultados(:,3)=filter(b,a,y);
plot(t,y,t,resultados(:,1),t,resultados(:,2),t,resultados(:,3)) grid on; title('Sino signal: Filter 0.6-10, 0.65-10 y 0.7-10'); xlabel('Tiempo (s)'); ylabel('Señal'); legend('Sino','Filter 0.6-10','Filter 0.7-10','Filter 0.8-10');
You have also asked me abouy wp parameter, it is a parameter of butterworth filter.
[B,A] = butter(N,Wn) designs an Nth order lowpass digital
Butterworth filter and returns the filter coefficients in length
N+1 vectors B (numerator) and A (denominator). The coefficients
are listed in descending powers of z. The cutoff frequency
Wn must be 0.0 < Wn < 1.0, with 1.0 corresponding to
half the sample rate.