Is it possible to generate the same function for identical subsystems in different top models?

1 回表示 (過去 30 日間)
JW Sun
JW Sun 2023 年 7 月 31 日
回答済み: Kanishk 2024 年 9 月 16 日
I'm now developing several top models with Simulink. In my plan, code generation should be done seperately for each top mode, and the code generated will be integrated into the same project. In the different top models, there are some identical subsystems. Is there a way to generate the same function for these identical subsystems in the whole project?

回答 (1 件)

Kanishk
Kanishk 2024 年 9 月 16 日
Hi JW,
I understand you want to generate reusable code for subsystems shared across multiple models. For this, you can utilize a "Library Subsystem."
Please follow the steps outlined below to use the “Library Subsystem”
  • Convert the subsystem into a library block by pasting it in a Blank Library document from Simulink start page.
  • Configure it to be atomic unit and support reusable code generation from Code Generation tab in Block Parameters.
  • Save the library on MATLAB path and use the library block as subsystem in the models.
  • Reusable code files (.C and .H) for the subsystem will be obtained after code generation which can be used throughout the whole project.
Here are the detailed steps to use the “Library Subsystem” from the official MathWorks documentation.
Hope this helps!
Thanks

カテゴリ

Help Center および File ExchangeDeployment, Integration, and Supported Hardware についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by