主要内容

Generate and Simulate Standalone FMU in Simulink

Simulink FMU Builder enables you to generate FMUs from your Simulink models and C/C++ code. You can generate Co-Simulation and Model Exchange FMUs that are compatible with FMI 2.0 and 3.0 standards. To learn about FMI and FMU concepts, see Functional Mockup Interface Concepts.

Comparison of FMU with Simulink Alternatives

FMUs provide a way to package your system components into standalone units. Simulink provides alternatives for generating standalone packages from Simulink models or C/C++ code. You can use protected models to generate a standalone package from Simulink models and C MEX S-function to generate standalone S-functions from C/C++ code.

General considerations

This table provides general considerations for choosing a tool to generate your standalone package.

Working EnvironmentSimulink ModelC/C++ Code
Requires InteroperabilityModel to FMUCode to FMU
Used only in SimulinkProtected ModelC MEX S-Function

Generate Ready-to-run Packages for Simulink Models

You can use FMUs or protected models to generate standalone packages from your Simulink models. Use FMUs when you need interoperability with other tools and plan to share the package outside Simulink. Use Simulink protected models when you are modeling, generating, and integrating the components in the Simulink environment and interoperability with other tools is not required. This table provides a detailed comparison between FMU and protected models.

FeatureFMUProtected Model
Tool compatibilityTool-independentSimulink only
Multi-platformYes; can package multiple binariesNo; single-platform
Bus interfaceSupports non-virtual busses onlyFull bus support
Advanced Simulink Semantics (for example fixed-point, Simscape solver)LimitedFull compatibility
Simulation fidelityHigh for Model Exchange; solver and importer dependent for Co-SimulationHigh
Intellectual property protectionProtected by compilation (binary files)Protected by encryption, (password protection), compilation (binary), and obfuscation (source code)
Debugging capabilitySignal and source-code based debuggingHidden model details

Generate Ready-to-run Packages for C/C++ Code

You can use the Code to FMU tool or a C MEX S-function to generate standalone units for your C/C++ code. Use FMUs when you need interoperability with other tools and to share the package outside Simulink. Use a C MEX S-function when you are modeling, generating, and integrating the components entirely within the Simulink environment. This table provides a detailed comparison between FMU and C MEX S-functions.

FeatureFMUC MEX S-Function
Tool CompatibilityTool-independentSimulink only
Multi-platformYes; can package multiple binariesNo; single-platform
System Composer integrationYesNo; can be included in Simulink Subsystem or Model Reference
Fixed-point compatibilityNoYes
Simulation fidelityHigh for Model Exchange; solver and importer dependent for Co-SimulationHigh
Modeling and integration complexityModerateComplex

You can generate Co-Simulation or Model Exchange FMUs for both Simulink models and C/C++ code. To learn more about these FMU types, see FMU Types: Co-Simulation and Model Exchange.

Co-Simulation FMU Solvers: Fixed-Step and Variable-Step

A Co-Simulation FMU that contains both the model and solver can use either a fixed-step or variable-step solver. A fixed-step FMU can run independently of the original modeling environment and does not require additional runtime dependencies. A variable-step co-simulation FMU that is generated from Simulink offers limited Simulink semantics support, does not support cross-compilation, and depends on the MATLAB Runtime (MCR) to execute. As a result, variable-step FMUs are less portable and require the target environment to have the necessary runtime libraries installed.

FeatureFixed-Step FMUVariable-Step FMU
MATLAB RuntimeDoes not require MATLAB RuntimeRequires MATLAB Runtime
Cross-platform compilation and simulationYesNo
Cross-release simulationYesNo
FMUState supportYesNo
Windows 32-bit DLLYesNo
Multi-Instance supportYesNo

Generate FMUs in Simulink

Simulink FMU Builder and Simulink enable you to generate FMU from Simulink models or C/C++ and simulate these in the Simulink environment. Simulink FMU Builder supports generation of FMUs compatible with the FMI 2.0 and FMI 3.0 standards.

Import and Simulate FMUs in Simulink

Simulink provides a wide range of features that enhance the usability and integration of FMUs within its environment. Through support for FMI standards and integration with native Simulink capabilities, you can incorporate FMUs into a model development workflows for simulation, verification, and deployment. This enables FMUs to function as integral components within Simulink based systems, supporting a range of development and testing activities. For more information, see Import, Test, and Simulate FMUs in Simulink.

See Also

Topics

External Websites