How to use multiple Simulink code generated models in a project?
5 次查看(过去 30 天)
显示 更早的评论
I have an embedded project I am working on where I want to split my simulink model into multiple sub-models and generate code for each separately. If I generate code for each model separately, then the rtU and rtY structures end up get redefined when I include multiple code generated libraries in my project.
Is there a way to configure code generation to avoid this issue?
I have tried changing model settings>code generation>code interface>code interface packaging to "reusable function" and that resolves my concerns with rtU and rtY, but then RT_MODEL is redefined in each generated header file (also I do not know how I am supposed to use the argument "RT_MODEL *const rtM" for the initialization and step functions.
Any inputs/guidance would be great!
0 个评论
采纳的回答
Jacob Mathew
2025-6-2
Hey Hareesh,
As you have mentioned "...where I want to split my simulink model into multiple sub-models and generate code for each separately." it seems to me like you are on track to do Component Based Modeling. You can refer to the following guide to get started on what it is, its advantages and how to approach it based on your requirements:
You have already mentioned that you are setting the interface packaging to Reusable Function but just to double check, you can refer to the following to differentiate between Reusable and Non Resuable Functions:
Finally, specific to RT_Model getting redefined, you can refer to the following MATLAB Answers Post to troubleshoot:
4 个评论
Jacob Mathew
2025-6-5
Hey Hareesh,
Component based Modeling deals with the identical idea of having multiple different models in your project. The idea is to have certain sub components or sub systems that you can change on the fly as you adapt your design. Using Referenced Models is part of the component based modeling approach and it avoids naming conflicts by encapsulating code for each referenced model using seperate namespaces. You can refer to the following documentaion to guide you:
Alternatively, if you want to manually customise the model variable names and namespaces, you can follow the below documentation on Customising Generated Identifiers:
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!