Using Savitzky-Golay filter in real time simulink model
31 次查看(过去 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!