Help with butterwort filter

1 view (last 30 days)
Sam
Sam on 3 Jan 2015
Edited: Star Strider on 3 Jan 2015
It's hard for me to understand all the mathematics behind the filters, but I found two possible ways to design a Butterwort filter. They give both the same values for Fs,Fc,Fz and Fn. But still there are differences in the output 'a' and 'A'and in 'b' and 'B'. I need to design a filter with cutoff-frequency of 6Hz and it has to be of the 4the-orde low-pass.
The first way:
cutoff=6;
order=4;
fs_v= data_stair_rise(1, 1).VideoFrameRate ;
[b,a] = butter(order,cutoff/(0.5*fs_v),'low'); %I don't know why to divide the cutoff by (0.5*fs_v)...
The second way:
Fs1 = data_stair_rise(1, 1).VideoFrameRate; % Sampling Frequency is 100 for my data
Fn1 = Fs1/2;
Fc1 = 6/Fn1;
Fz1 = 7/Fn1;
[n,Wn] = buttord(Fc1, Fz1, 1, 10); % I don't know what the 1 and 10 stands for...
[B,A] = butter(n,Wn);

Answers (1)

Star Strider
Star Strider on 3 Jan 2015
Edited: Star Strider on 3 Jan 2015
You divide the design passband and stopband frequencies by 0.5*fs_v to normalise them by the Nyquist frequency (the highest resolvable frequency in a sampled signal).
[n,Wn] = buttord(Fc1, Fz1, 1, 10); % I don't know what the 1 and 10 stands for...
They are the passband ripple magnitude (in dB), and stopband attenuation (in dB), respectively.
The two filters are different. The top filter you chose to be 4th-order, while the buttord function chooses 12th-order.
Understanding the mathematics behind filter design simply takes time. When you have the opportunity, take a course in digital signal processing.
  2 Comments
Sam
Sam on 3 Jan 2015
Thanks! How can I design the second one (with the buttord function) to be a 4th-order with a cutoff-frequency of 6Hz? And is the top filter a 4th-order filter with cutoff-frequency of 6 Hz?
Star Strider
Star Strider on 3 Jan 2015
Edited: Star Strider on 3 Jan 2015
My pleasure!
The buttord function will calculate the optimal parameters for your filter. If you want to use those results, do everything in the code you quoted in ‘the second way’. That will likely be a better and more stable filter.
If you want a 4th-order filter with a cutoff frequency of 6 Hz, and a sampling frequency of 100 Hz (Nyquist frequency of 50 Hz), define it as:
[b,a] = butter(4, 6/50);
I would look at all the filters with the freqz function to see how they differ.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!