Export and Import Function Mockup Unit (FMU) from Model with Variant Subsystem Blocks
This example shows you how to export a standalone Functional Mock-up Unit (FMU) from a model containing a Variant Subsystem block, then import it into a new model.
Explore and Export Model to Standalone FMU
1. Open the model
slexVariantSubsystems. The model contains a variant subsystem block
Controller with two choices
Linear Controller and
Nonlinear Controller with the conditions
VSS_MODE == 1 and
VSS_MODE == 2 respectively.
2. Set Variant activation time to
startup in the Block Parameters dialog box of the Controller block. Also, set the Linear Controller and Nonlinear Controller choices as atomic.
set_param('slexVariantSubsystems/Controller','VariantActivationTime', 'startup'); set_param('slexVariantSubsystems/Controller/Linear Controller', 'TreatAsAtomicUnit', 'on'); set_param('slexVariantSubsystems/Controller/Nonlinear Controller', 'TreatAsAtomicUnit', 'on');
3. Set the active choice to
Nonlinear Controller by setting
2, then simulate the model.
VSS_MODE = 2; sim('slexVariantSubsystems');
4. To export the model to an FMU:
a. In the Simulation tab, click the Save drop-down.
b. In the Export Model To section, click Standalone FMU.....
c. In FMU Export dialog, specify the location to save the FMU to be generated.
d. Click Create to export to FMU.
The generated FMU file, with the extension
.fmu is at your specified location. You can now use this FMU file in the FMU block.
Create Model with Standalone FMU
The FMU block lets you import your applications, contained in FMUs, into Simulink® to create a model with a standalone FMU.
To create a standalone FMU:
1. Create a model and add an FMU block from the Simulink Extras/FMU Import library.
2. Specify the name of the generated FMU file in the FMU name parameter in the Block Parameters dialog of the FMU block. The FMU block icon and port labels update to the labels of the corresponding FMU. You now have a standalone FMU.
When you double-click the FMU block, the Parameters tab of the Block Parameters has the same active choice as when you export the FMU, as the parameter
VSS_MODE is equal to
2. You can change the value of the active choice by changing