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개)

카테고리

Help CenterFile Exchange에서 Smoothing and Denoising에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by