フィルターのクリア

How do I get back filtered data using 'filter' after after getting the digital filter from bandpass?

2 ビュー (過去 30 日間)
Hello everyone, I'm trying to figure out the bandpass and filter function, which I am using to filter out signals in the range of 1.9 to 4.1 from my data. My code below is based on the documentation. Basically, after getting the digital filter, d, from bandpass(), I tried using filter to get back the filtered signals, but I cannot seem to get the same output as from when using bandpass. Thank you in advance!
load data
fs = 24;
figure
bandpass(data,[1.9 4.1],fs)
[~, d] = bandpass(data,[1.9 4.1],fs);
figure
plot(filter(d, data))
[~, d] = bandpass(x,[100 200],fs);
figure
plot(filter(d, data))

採用された回答

Chunru
Chunru 2021 年 6 月 11 日
編集済み: Chunru 2021 年 6 月 11 日
% load data
data = randn(512, 1);
fs = 24;
figure
% design filter, filter the data, plot the results
bandpass(data,[1.9 4.1],fs)
% desing the filter only
[~, d] = bandpass(data,[1.9 4.1],fs);
% filter the data using the filter object. (bandpass use filtfilt
% internally by default)
xf = filtfilt(d, data);
% compare the origninal and the filtered signal
t =(0:length(data)-1)/fs;
figure
plot(t, data, 'b', t, xf, 'r');
legend('Original', 'Filtered');
  2 件のコメント
Ikmal Rosli
Ikmal Rosli 2021 年 6 月 11 日
thank you. by the way, this may be a dumb question, but how do I check, the default function used in bandpass?
Chunru
Chunru 2021 年 6 月 11 日
編集済み: Chunru 2021 年 6 月 11 日
Hi. The question is not dumb. :-).
You can search document, eg. doc bandpass
Many matlab function has source code. You can edit bandpass. Then you can debug the program by stepping through.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSmoothing and Denoising についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by