Butter bandpass filter - why the Wp 0.4 doesn´t works and 0.6 does?

6 views (last 30 days)
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.
  1 Comment
Jan
Jan on 20 Nov 2012
Edited: Jan on 20 Nov 2012
What do you exactly mean by "does not work"? A description would be helpfuil to understand what your actual problem is.
Your code does not contain a variable called "wp". Are you talking of f(1) and f(2)?

Sign in to comment.

Accepted Answer

nani
nani on 28 Nov 2012
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.
  6 Comments
nani
nani on 30 Nov 2012
I have observed that you won´t see the files i have sent. So I have upload it in a zip file using matlab file exchange option "http://www.mathworks.com/matlabcentral/fileexchange/new" Mi file name is "Butter bandpass filter.zip" Thank so much. best regards.
Jan
Jan on 30 Nov 2012
Edited: Jan on 30 Nov 2012
@nani: This is not the purpose of the FileExchange.
I'm asking the 3rd and last time for the application of a proper code formatting. A formatted code would encourage forum users to care about your questions.
Currently this thread conatins a lot of DON'Ts in this forum:
  1. "does not work" without details
  2. Code added in an answer, although this contains in the original question
  3. Answer posted instead of a comment
  4. This answer is accepted, such that the thread is marked as solved, although it is not
  5. A link is posted, which does not work. Instead of removing it, a further comment is added.
  6. Further code is posted in the FileExchange, but this is not its purpose.
  7. And still the question is not clear.
I suggest to restart: You can create a new thread, ask as clear as possible, add a screenshot (instructions can be found in the forum), and finally delete this thread and the FEX submission, when it will appear (perhaps on Monday).

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!