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?
No products are associated with this question.
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.
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.