Query about Butterworth filter

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

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.
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

Hi.
After another discussion with my friend, he is telling that the frequency response of the signal is showing frequency components of 12.5 Hz exists so we have to use greater frequency. Here is his codes and the response of the signal. Does this mean we have to use 25 Hz for sampling frequency. Also his argument is that 10 Hz is not at all sampling frequency but it is mere acquisition rate. This is really confusing for me. :'(
Fs =25 ;
T = 1/Fs;
Nfft = length(pa);
f = -Fs/2:Fs/Nfft:Fs/2-Fs/Nfft;
figure(4);
fx=20*log10(abs(fft(pa,Nfft)));
plot(f,fx)
Also I have attached the frequency response and fft plot.
Awaiting your response.
The rate a signal is recorded is called "sampling rate" also. When you record a signal with 10 Hz, you cannot find frequencies with more than the Nyquist frequency (here 5 Hz) in it. This is the meaning of the Nyquist theorem. Therefore you cann find frequency components at 12.5 Hz.
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.
That's a lot helpful. Thanks a lot Jan and Wayne. Appreciate the help.

Sign in to comment.

More Answers (1)

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!