Main Content

Export Simulink Model to Standalone FMU

This example shows how to export Simulink® component to standalone Co-Simulation FMU 2.0 with Simulink Compiler™. For a detailed explanation of the model, see:

In this example, the air-fuel ratio control system is composed of three Simulink models:

  • Fuel Rate Control Component: fmudemo_export_fuelsys_controller,

  • Engine Gas Dynamics Component: fmudemo_export_fuelsys_plant, and

  • top-level model fmudemo_export_fuelsys_top.

Once the controller and plant components are exported to FMU format, they can be integrated using the top-level model. The generated FMUs can also be imported into other simulation tools that support FMI. For a list of Tools that support FMI, see:

Export Fuel Rate Control Component to FMU

Open the fmudemo_export_fuelsys_controller example model.

From Simulation tab, click drop-down button for Save. In Export Model To section, click Standalone FMU.... In FMU Export dialog, configure wrapper model and icon settings, and specify save location for generated FMU.

Click Create to export to FMU. The fmudemo_export_fuelsys_controller.fmu file can be found at specified save location.

Export Engine Gas Dynamics Component to FMU

Open the fmudemo_export_fuelsys_plant example model.

FMU can also be exported using command-line. In MATLAB® command line window, use exportToFMU2CS command:

% Export model to Standalone Co-Simulation FMU 2.0
exportToFMU2CS('fmudemo_export_fuelsys_plant', 'CreateModelAfterGeneratingFMU', 'off', 'AddIcon', 'snapshot', 'SaveDirectory', pwd);

You can use optional arguments CreateModelAfterGeneratingFMU, AddIcon, and SaveDirectory to configure FMU export settings. For more information, call help ExportToFMU2CS.

Integrate FMU Components in Simulink

Once both FMUs are successfully exported, you may use the top model fmudemo_export_fuelsys_top to fully integrate the system for testing.