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

1 visualizzazione (ultimi 30 giorni)
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 Commento
Jan
Jan il 11 Ago 2022
Modificato: Jan il 11 Ago 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).

Accedi per commentare.

Risposta accettata

Joe Vinciguerra
Joe Vinciguerra il 23 Ago 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.

Più risposte (0)

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by