How to get the same filtered results from signal processing tool box using functions?

1 次查看(过去 30 天)
Hi, I have a question about filtering using MATLAB.
this is my data
readtable('data.csv')
ans = 541×1 table
Var1 ______ 59.332 58.728 57.993 57.118 55.805 54.072 52.431 51.219 50.026 48.35 46.418 44.741 43.431 42.304 41.223 40.18
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 个评论
Jan
Jan 2022-8-11
编辑:Jan 2022-8-11
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).

请先登录,再进行评论。

采纳的回答

Joe Vinciguerra
Joe Vinciguerra 2022-8-23
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 个)

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by