How can I work around the limitation that code generation with the S-Function target is not supported with Initialize Function blocks in Simulink R2023b?

I am using Simulink R2023b. I am using the S-Function target file "rtwsfcn.tlc" to generate an S-Function from my model "CodegenModel.slx".
The model "CodegenModel.slx" uses an "Initialize Function" block. When I try to generate an S-Function from the model, I get the error
Code Generation using the rsim, asap2 or RTW S-Function targets are not supported in models such as 'CodegenModel', which contain Initialize, Reset or Terminate Function blocks
How can I work around this error?

 Accepted Answer

To work around this error, you can generate a Protected Model from your Simulink model that uses "Initialize function" blocks instead of generating an S-Function. Protecting models is a preferred solution for IP protection, and you can place protected models in other Simulink models to reuse your component.
For more alternatives to the S-Function target, see the note on top of the documentation page, "Use S-Function Target for Model or Subsystem":
https://www.mathworks.com/help/releases/R2023b/rtw/ug/generated-s-function-block-deployment.html

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products

Release

R2022b

Community Treasure Hunt

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

Start Hunting!