How to get the same filtered results from signal processing tool box using functions?
1 view (last 30 days)
Show older comments
Hi, I have a question about filtering using MATLAB.
this is my data
readtable('data.csv')
And I wish to apply Savitzky-Golay filter using
sgolayfilt()
and get the same results from the same filtering in Signal Processing Toolbox (which are much smoother) .
However, when I tried, I get following results
filtered data using sgolayfilt(data, 3, 11) above
filtered data using signal processing tool box with all options 'auto'
I wish to know how toget below figure without using the toolbox.
Is there any way?
Thank you.
1 Comment
Jan
on 11 Aug 2022
Edited: Jan
on 11 Aug 2022
When I load your data, I get a different signal:
It looks like you have posted a cropped signal here. Then an exact omparsion is hard. Please post the data you are actually working with.
With sgolayfilt(data, 3, 51) the output looks like your screenshot (except for the cropping).
Accepted Answer
Joe Vinciguerra
on 23 Aug 2022
To see what the Signal Analyzer is doing under the hood to your data, click the "Analyzer" tab and select "Generate Function". Smoothing the data with the Savitzky-Golay method and otherwise "default" settings should produce the following output when you generate the function:
function y = preprocess(x)
% Preprocess input x
% This function expects an input vector x.
% Generated by MATLAB(R) 9.12 and Signal Processing Toolbox 9.0.
% Generated on: 23-Aug-2022 15:27:06
y = smoothdata(x,'sgolay');
You can see here that Signal Analyzer isn't directly calling the sgolayfilt function, but the smoothdata function with the sgolay method and default parameters (default degree = 2, window is determined heuristically). Check out the help page for more details.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!