Filter Sound from Data

1 回表示 (過去 30 日間)
Sam Hurrell
Sam Hurrell 2022 年 2 月 22 日
コメント済み: Star Strider 2022 年 2 月 22 日
I have frequency-based data sets (with column 1 for time and column 2 for amplitude), and I use the following code to filter out the sound. I'm not convinced that this is the most effective system as I believe this process changes the time at which other signals occur. Is there a better system for filtering data?
BP = [0.8725 0.8925]; %Frequency filter band
Fs = 1/(data(2,1)-data(1,1)); %Sampling Freq.
Y00 = bandpass(data(:,2),BP,Fs); %Filtered data

回答 (2 件)

Jan
Jan 2022 年 2 月 22 日
filtfilt works without shifting the data.
  1 件のコメント
Sam Hurrell
Sam Hurrell 2022 年 2 月 22 日
How is filtfilt different to Bandpass?

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


Star Strider
Star Strider 2022 年 2 月 22 日
That appears to me to be correct.
If you are using the same filter for all the data sets, return the digital filter object after the first set:
[Y00,df] = bandpass(data(:,2),BP,Fs, 'ImpulseResponse','iir'); %Filtered data
to design an elliptic filter (see ellip for details) and return it as well.
Then in subsequent data sets, use it with filtfilt to do the filtering:
Y01 = filtfilt(df, data2(:,2));
That elimiinates the computational expense of designing the same filter for each signal.
.
  2 件のコメント
Sam Hurrell
Sam Hurrell 2022 年 2 月 22 日
Apologies as I am not well versed in Matlab, but what dyou mean by "return the digital filter", and how does this work with filtfilt?
Star Strider
Star Strider 2022 年 2 月 22 日
The bandpass and related functions optionally return the digital filter object they created as the second output. See for example the Bandpass Filter Steepness section of the documentation.
data = randn(500,2); % Create Matrix
data(:,1) = linspace(0, 499, 500)'/100;
data2 = randn(500,2); % Create Matrix
t = data(:,1);
BP = [0.8725 0.8925]; %Frequency filter band
Fs = 1/(data(2,1)-data(1,1)); %Sampling Freq.
[Y00, df] = bandpass(data(:,2),BP,Fs,'ImpulseResponse','iir'); %Filtered data
Y01 = filtfilt(df, data2(:,2));
figure
plot(t, Y00)
grid
figure
plot(t, Y01)
grid
The data are synthetic, however the code demonstrates the correct procedure.
.

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

カテゴリ

Help Center および File ExchangeSingle-Rate Filters についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by