Can u use filtfilt with structfun?
1 view (last 30 days)
Show older comments
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);
0 Comments
Accepted Answer
Rik
on 11 Aug 2021
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);
More Answers (1)
Chunru
on 11 Aug 2021
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
0 Comments
See Also
Categories
Find more on Digital Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!