Help with filtering a signal

I am trying to filter a signal that is imported though by a txt file and I am getting an error. The signal has a sampling frequency of 1000.
data = importdata('data.txt');
fs = 1000;
R = data.data(:,1);
my_filt(R,50, 1000, 1)
Error using filtfilt
Expected input to be finite.
Error in filtfilt>efiltfilt (line 114)
validateattributes(x,{'double'},{'finite','nonempty'},'filtfilt');
Error in filtfilt (line 89)
y=efiltfilt(b,a,x);
Error in my_filt (line 30)
smoothed_data=filtfilt(B,A,raw_data);
Thanks!

4 件のコメント

James Browne
James Browne 2019 年 6 月 12 日
Hi,
So it looks like you have a user defined function called my_filt() which is calling the filtfilt() function. The error is coming from the my_filt() function. I am not familiar with the filtfilt() function so I do not recognize the errors.
So without seeing the code for my_filt() function, it would not be possible to say more than the fact that it looks like the filtfilt() function is not getting compatible input syntax from within the my_filt() function.
Hope that at least points you in the right direction~
NAS
NAS 2019 年 6 月 12 日
the my_filt is a function and looks like this:
function [smoothed_data] = my_filt(raw_data,fc, fs, type)
warning off
%calculate wn
wn = 2*fc/fs;
%calculate butterworth coefficients (2nd order)
if type == 1
[B,A]=butter(2,wn);
end
if type == 2
[B,A]=butter(2,wn,'high');
end
%calculate smoothed data using a zero-phase lag routine
smoothed_data=filtfilt(B,A,raw_data);
warning on
Walter Roberson
Walter Roberson 2019 年 6 月 12 日
find(~isfinite(R))
NAS
NAS 2019 年 7 月 12 日
Thanks!

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSignal Processing Toolbox についてさらに検索

タグ

質問済み:

NAS
2019 年 6 月 12 日

コメント済み:

NAS
2019 年 7 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by