How can I do/implement Low pass filter function in matlab?
Mostrar comentarios más antiguos
Hi !
how can I use/do LOW PASS FILTER in matlab? I want to determine as inputs the cut off frequency .. and I want also as second input to enter to LOW PASS FILTER the signal (it's a vector) , so Im trying to do LOW PASS FILTER function called function Low_Pass_Filter(first input the cutoff frequency that I want to input it to my LOW PASS FILTER, Second input is the signal which it's a vector 1X10k size) .. any help please how can I do that in matlab?
thanks alot!
1 comentario
Satyam
el 2 de Nov. de 2023
type fdatool in matlab command prompt and there you will get all options for realizing a filter
Respuestas (1)
Star Strider
el 22 de Jun. de 2020
0 votos
Otherwise, it is straightforward to define filters with the Signal Processing Toolbox functions. Note that you need to define the sampling freuqency of the signal in order to define the cutoff frequency correctly.
4 comentarios
Mohamed Jamall
el 22 de Jun. de 2020
Star Strider
el 22 de Jun. de 2020
You are welcome to explore the lowpass code on your own at your leisure.
Here is some archive example code, with the time vector ‘t’ and ‘signal’ the vector to be filtered:
Fs = 1/mean(diff(t)); % Sampling Frequency
L = numel(t); % Signal Length
Fn = Fs/2; % Nyquist Frequency
Wp = 0.05/Fn; % Passband Frequency (Normalised)
Ws = 0.06/Fn; % Stopband Frequency (Normalised)
Rp = 1; % Passband Ripple
Rs = 60; % Passband Ripple (Attenuation)
[n,Wp] = ellipord(Wp,Ws,Rp,Rs); % Elliptic Order Calculation
[z,p,k] = ellip(n,Rp,Rs,Wp,'low'); % Elliptic Filter Design: Zero-Pole-Gain
[sos,g] = zp2sos(z,p,k); % Second-Order Section For Stability
figure
freqz(sos, 2^16, Fs) % Filter Bode Plot
signal_filt = filtfilt(sos, g, signal); % Filter Signal
Note that this code has a passband frequency of 0.05 Hz and a stopband frequency of 0.06 Hz. Use values that make sense in your application.
See the documentation for the various functions to understand how they work, and the reason I use them.
This is one of many examples of filter design I have posted over the years. For more of them, search Answers.
.
Mohamed Jamall
el 22 de Jun. de 2020
Editada: Mohamed Jamall
el 22 de Jun. de 2020
Star Strider
el 22 de Jun. de 2020
My code is intended for signal processing, not communications. I have essentially no experience with digital communications protocols. You will need to experiment to be certain my code does what you want in your application.
Categorías
Más información sobre Signal Processing Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!