How can I do/implement Low pass filter function in matlab?
显示 更早的评论
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 个评论
Satyam
2023-11-2
type fdatool in matlab command prompt and there you will get all options for realizing a filter
回答(1 个)
Star Strider
2020-6-22
0 个投票
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 个评论
Mohamed Jamall
2020-6-22
Star Strider
2020-6-22
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
2020-6-22
编辑:Mohamed Jamall
2020-6-22
Star Strider
2020-6-22
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Signal Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!