Using Savitzky-Golay filter in real time simulink model
27 ビュー (過去 30 日間)
古いコメントを表示
I want to use Savitzky-Golay filter in my simulink model. This function is available in matlab as this outputsignal=sgolayfilt(inputsignal,order of filter,window size);
The way it works is as follows from some reading in the internet: It uses least squares to regress a small window of your data onto a polynomial, then uses the polynomial to estimate the point in the center of the window. Finally the window is shifted forward by one data point and the process repeats. This continues until every point has been optimally adjusted relative to its neighbors. It works great even with noisy samples from non-periodic and non-linear sources.
I am unable to use this function in simulink. Can this be achieved in simulink using a matlab function block?
Note: I would like to generate embedded code with this,hence the need to do it in simulink.
0 件のコメント
採用された回答
Sudarshan Kolar
2017 年 8 月 28 日
Hi Vishal,
I am attaching a demo model for your reference. Hope that helps.
Note:
1. Since 'sgolayfilt' requires a vector input, the buffer block is used to collect the scalar inputs and present it as a vector to the Matlab Function block.
2. Also, the outputs are displayed using vector scope instead of normal scope.
Regards -Sudarshan
4 件のコメント
DN
2018 年 12 月 15 日
Sudarshan, I think you are missing the point in your answer....it throws an error and question clearly states for code generation
Error:
The function 'sgolayfilt' is not supported for standalone code generation. See the documentation for coder.extrinsic to learn how you can use this function in simulation.
Function 'MATLAB Function' (#23.33.51), line 3, column 5:
"sgolayfilt(u,3,11)"
Launch diagnostic report.
Component: MATLAB Function | Category: Coder error
Errors occurred during parsing of MATLAB function 'MATLAB Function'
Have, you considered HDL coder blocks that would be compatible, this will then easily generate into code and can be synthesised ?
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!