How can I create nested FMUs with tunable parameters in Simulink?

조회 수: 14 (최근 30일)
I am using MATLAB 2022b and am trying to export a nested FMU in Simulink. I want to create FMUs, import them into my model, then export that model as another FMU. I also want the end user, who might not use or have access to Simulink, to be able to tune parameters for any inner FMUs that I have.
Is there a way to do this workflow?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2023년 3월 16일
To do this workflow, follow these steps:
  1. Create the inner FMUs. To do this, create a Simulink model and determine which parameters you would like to let the user tune. Those parameters need to be defined in the Model Workspace as variables or Simulink Objects. Then, go to the Model Explorer, navigate to the Model Workspace, and set their "Argument" checkbox to true. This will allow it to be exported.
  2. To check that it will be exported, go to Save --> Export as Functional Mockup Unit (FMU). The parameter should appear with its defined name under the "Access the Parameters of the FMU" section. The Export checkbox needs to be set for it to work. You can now export the FMU. A .FMU file should be created in your directory.
  3. To create the top level model, create a new model and use the "FMU Import Block" to import the .FMU file that was just created.
  4. Create the top level and nested parameters. When the .FMU file is imported into the top level model, it will have a parameter in it with the value set to what it was in the original file. However, the top level model cannot directly access this parameter. Instead, go to the Model Explorer and create a new Simulink object or variable in the Model Workspace. Set the "Argument" checkbox to true.
  5. Link the top level and nested parameters. Go to the "FMU Import Block" and adjust the value of the nested parameter to the name of the variable that you just created. Now, the top level parameter is linked to the nested parameter.
  6. Follow the same steps to export the top level model as an FMU.
Attached are basic files to represent what this workflow might look like. "FMU_A" is the nested FMU and "TopLevel" is the top level Simulink model that can be exported.
Portions of this workflow can be done programmatically. Consult the following documentation pages to learn more about exporting FMUs:
 

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Create Standalone FMU에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by