Why is my custom System object not compatible with code generation?

11 Ansichten (letzte 30 Tage)
I have a Simulink model that I created in R2022a and that contains a MATLAB System block that uses a custom System object. My System object has relatively simple methods and only a few properties (a public, tunable property, a public, variable-size, discrete state property, and a few other private properties).
When I run my model in "Interpreted execution" mode, my model simulates as expected. However, when I run my model in "Code generation" mode, I run into the following error stating that my System object is using code that does not support code generation.
The error occurred for MATLAB System block 'MATLABSysObjCodeGenTest/MATLAB System'.
To prevent this error, use one of the following:
* Modify the System object to avoid code that does not support code generation.
* Change 'Simulate using' parameter to 'Interpreted Execution'.
 How can I make my System object code generation compatible?

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 2 Feb. 2023
In order for MATLAB System blocks to be code generation compatible, you cannot use variable-size for discrete state properties of System objects; however, private properties can be variable-size. The following link outlines this requirement along with others for specifically making System objects compatible with code generation:
Changing the public, variable-size, discrete state property to a private property instead should allow for the model to be code generation compatible. 

Weitere Antworten (0)

Kategorien

Mehr zu Simulink Coder finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by