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

11 ビュー (過去 30 日間)
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?

採用された回答

MathWorks Support Team
MathWorks Support Team 2023 年 2 月 2 日
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. 

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by