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!