How to design a lowpass filter?

17 ビュー (過去 30 日間)
Marcel345614
Marcel345614 2021 年 5 月 4 日
編集済み: Marcel345614 2021 年 5 月 4 日
I would like to filter the following data:
Obviously the data shows some oscillations with a quite constant frequency. How can I design an appropriate (low pass?) filter to filter out this noise?
(Matlab 2020b)

回答 (1 件)

Scott MacKenzie
Scott MacKenzie 2021 年 5 月 4 日
編集済み: Scott MacKenzie 2021 年 5 月 4 日
You can use smoothdata as a quick-and-dirty low pass filter:
% sine wave with noise example
y1 = sin(linspace(0,20*pi,200));
y1 = y1 + rand(1,200);
y2 = smoothdata(y1, 'movmean', 5); % through lp filter
% square wave example
y3 = repmat([1 0], 10, 10);
y3 = y3(:);
y4 = smoothdata(y3, 'movmean', 5); % through lp filter
tiledlayout(2,2);
nexttile(1);
plot(y1);
ax = gca;
ax.YLim = [-2 2];
nexttile(3);
plot(y2);
ax = gca;
ax.YLim = [-2 2];
nexttile(2);
plot(y3);
ax = gca;
ax.YLim = [-2 2];
nexttile(4);
plot(y4);
ax = gca;
ax.YLim = [-2 2];
You can increase the 3rd argument in smoothdata to get more aggressive filtering.
  1 件のコメント
Marcel345614
Marcel345614 2021 年 5 月 4 日
編集済み: Marcel345614 2021 年 5 月 4 日
Thanks for your answer!
Does someone know an method to only filter the oscillating frequency. A moving average filter is good, but is not always what I should use.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatched Filter and Ambiguity Function についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by