Query about Butterworth filter

9 views (last 30 days)
Hi.
I am relatively new to Matlab and I am not from Signal processing background, so pardon my ignorance. I have a fluid pressure data acquired at 10 Hz from the sensor, which I wish to filter using low-pass filter. I measured for 51s to acquire 510 samples of pressure data. I saw this code in the internet which I modified to suit my data:
pa=data(:,3); % extracting third column from the acquired data
t1=data(:,1); % time data from first column
t1=t1-min(t1); % resetting the start time to zero
cut_off_freq = 0.2; % normalised cut-off frequency
sampling_freq = 10; % acquisition rate of the measurement device
number_of_point = length(pa);
order = 2;
[butter_b, butter_a] = butter(order, cut_off_freq/(sampling_freq/2));
freqz(butter_b, butter_a, number_of_point, sampling_freq);
y=filter(butter_b,butter_a,pa);
My friend tells me that the sampling frequency is the sampling frequency of the filter and not the actual measurement. He suggests me to use any frequency above 20 Hz (Nyquist criteria). But I am of the opinion that it should be 10, and we should play around the normalised cutoff frequency instead to come up with a proper filter. Who is right in this case?
Should sampling_freq=10 or should it be >20?
Thanks.
  2 Comments
Daniel Shub
Daniel Shub on 17 Jun 2013
This doesn't appear to be a MATLAB question. The answer is your sampling frequency is 10 Hz, but you need to understand the theory behind the differences between the continuous time Fourier transform and the DTFT (and to some extent the DFT) tp understand why.
Jan
Jan on 19 Jun 2013
Although the usage of normalized frequencies should be trivial, it took me some time to understand the underlying logic also. Therefore I've voted for this question.

Sign in to comment.

Accepted Answer

Wayne King
Wayne King on 17 Jun 2013
Edited: Wayne King on 17 Jun 2013
Your sampling frequency is 10 Hz as you correctly note. Therefore you should construct your cut_off_freq exactly as you do except use the cut_off_freq in Hz not in normalized frequency. So to have a cutoff frequency of 2 Hz is 2/5 in normalized units. The Nyquist frequency for your application is 5 Hz. Your friend is incorrect.
  4 Comments
Wayne King
Wayne King on 18 Jun 2013
Edited: Wayne King on 18 Jun 2013
Jan is correct. Sampling a signal at a given rate periodizes the spectrum with a period equal to the sampling rate. So the spectrum is completely characterized by one period ([-5,5] in this case for a real-valued signal). Just because you arbitrarily set the sampling frequency to some value and construct a frequency vector does not mean that there is signal energy at a given frequency. I can construct a frequency vector with arbitrary values and plot the fft() output against that vector if they are equal length.
Now whether the original analog signal was undersampled and therefore the spectrum is distorted by aliasing, that is another question. Still, that does not change the fact that your discrete-time signal was sampled at 10 Hz and this periodizes the spectrum to have a period of 10.
tranquiliser
tranquiliser on 19 Jun 2013
That's a lot helpful. Thanks a lot Jan and Wayne. Appreciate the help.

Sign in to comment.

More Answers (1)

Jan
Jan on 17 Jun 2013
As usual the documentation of butter reveals some details:
For data sampled at 1000 Hz, design a 9th-order highpass Butterworth filter
with cutoff frequency of 300 Hz, which corresponds to a normalized value of
0.6:
[z,p,k] = butter(9,300/500,'high');
...
So do not use the already normalized cut-off frequency in cut_off_freq/(sampling_freq/2), because this normalized it again.

Community Treasure Hunt

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

Start Hunting!