Can u use filtfilt with structfun?

2 ビュー (過去 30 日間)
Simon Hoffmann
Simon Hoffmann 2021 年 8 月 11 日
コメント済み: Simon Hoffmann 2021 年 8 月 11 日
I needed to segregate my signal due to noise in several parts of a long-term measuremt, which is why the remaining section have different lengths (which is why i am using a struct). Now i want to filter the signal parts with a cheby type 2 IIR filter, but i get the error:
"Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters."
% High-Pass filter with 0.4Hz Stopband-Frequency to remove the dc offset and trend from raw data
cheby_hp = designfilt('highpassiir', 'FilterOrder', 10, 'StopbandFrequency', 0.4, 'StopbandAttenuation', 80, 'SampleRate', 200);
% Detrend with IIR-HP filter
phases_struct_hp_filtered = structfun(@filtfilt(cheby_hp), phases_struct_appended,'UniformOutput', false);

採用された回答

Rik
Rik 2021 年 8 月 11 日
You need to use either a function handle, or create an anonymous function. Your syntax does neither. Try this modification.
% High-Pass filter with 0.4Hz Stopband-Frequency to remove the dc offset and trend from raw data
cheby_hp = designfilt('highpassiir', 'FilterOrder', 10, 'StopbandFrequency', 0.4, 'StopbandAttenuation', 80, 'SampleRate', 200);
% Detrend with IIR-HP filter
phases_struct_hp_filtered = structfun(@(x) filtfilt(cheby_hp,x), phases_struct_appended,'UniformOutput', false);
  1 件のコメント
Simon Hoffmann
Simon Hoffmann 2021 年 8 月 11 日
This works just fine, thank you for your fast reply!

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

その他の回答 (1 件)

Chunru
Chunru 2021 年 8 月 11 日
cheby_hp = designfilt('highpassiir', 'FilterOrder', 10, 'StopbandFrequency', 0.4, 'StopbandAttenuation', 80, 'SampleRate', 200);
% Detrend with IIR-HP filter
phases_struct_appended.n1 = randn(70,1);
phases_struct_appended.n2 = randn(40,1);
phases_struct_hp_filtered = structfun(@(x)filtfilt(cheby_hp, x), phases_struct_appended,'UniformOutput', false);
phases_struct_hp_filtered
phases_struct_hp_filtered = struct with fields:
n1: [70×1 double] n2: [40×1 double]

カテゴリ

Help Center および File ExchangeDigital Filtering についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by