Why is my custom System object not compatible with code generation?
조회 수: 11 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2023년 2월 2일
답변: MathWorks Support Team
2023년 2월 7일
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
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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!