How to create a filter with Hz and coefficient?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I got a very noisy signal and I would like to elimante the noise out of it.
According to a paper I should filter the data by "a filter between 0.5 and 35 Hz, using 8000 coefficient"
Does anybody know how to implement this in matlab? Or is there any "standard" code for this case?
Thank you for your help!
0 Kommentare
Antworten (1)
Star Strider
am 14 Aug. 2019
A filter with 8000 coefficients is likely an FIR filter. For a simple bandpass or bandstop application, an IIR elliptical filter is much more efficient.
If you have R2018a or later, use either the bandpass or bandstop functions, depending on what you want to do. They will design an efficient IIR filter that you can use with filtfilt if you need to use those filters on other signals. If you do not have an earlier release than R2018a, it is still straightforward to design an elliptical filter that will do what you want.
A functioning bandpass elliptical filter prototype for your application is:
Fs = 1000; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
Wp = [0.5 35]/Fn; % Passband Normalised
Ws = [0.25 40]/Fn; % Stopband Normalised
Rp = 1; % Passband Ripple (Irrelevant in Butterworth)
Rs = 50; % Stopband Attenuation
[n,Wp] = ellipord(Wp,Ws,Rp,Rs); % Order Calculation
[z,p,k] = ellip(n,Rp,Rs,Wp); % Zero-Pole-Gain
[sos,g] = zp2sos(z,p,k); % Second-Order Section For Stability
figure
freqz(sos, 2^16, Fs) % Filter Bode Plot
The only thing you may need to change is the sampling frequency (‘Fs’) to match the sampling frequency of your signal. Use filtfilt to filter your signal with this filter.
2 Kommentare
Star Strider
am 14 Aug. 2019
My pleasure.
That error is most likely caused by the sampling frequency ‘Fs’ being 80 Hz or lless for this filter. Ideally, the sampling frequency of your signal should be at least 90 Hz, and preferably higher (256 Hz).
Siehe auch
Kategorien
Mehr zu Digital Filtering finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!