Main Content

exportToFMU2CS

(To be removed) Export Simulink model to functional mock-up unit (FMU)

Since R2020a

exportToFMU2CS will be removed in a future release. Use exportToFMU instead.

Description

exportToFMU2CS(mdl) exports mdl to mdl.fmu. The model solver type must be fixed-step solver.

exportToFMU2CS(mdl,Name,Value) exports a model to a Functional Mock-Up Unit (FMU) using one or more Name, Value pair arguments.

Note

This function requires the FMU Builder for Simulink® support package.

example

Examples

collapse all

Export the model vdp to an FMU.

Open the model.

openExample('simulink_general/VanDerPolOscillatorExample');
open_system('vdp')

Set the solver type of the model to fixed-step.

set_param('vdp', 'SolverType', 'Fixed-step')

Export the model to vdp.fmu

exportToFMU2CS('vdp')

Input Arguments

collapse all

Name of the model to be exported to an FMU, specified as a string.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'CreateModelAfterGeneratingFMU','off'

Option to create model after export, specified as 'on' or 'off'. This argument creates a model, mdl_fmu.slx, that contains an FMU Co-Simulation block with the original model. Create this model to check the integrity of the exported FMU.

When set to 'off', no model is created.

Block icon or exported FMU image, character vector specified as one of these values:

  • 'off' – No block icon image.

  • 'snapshot' – Use image of model as block icon.

  • 'filepath' – Filepath of the image.

Option to generate 32-bit DLL, specified as 'on' or 'off'. Set the option to 'on' to support exporting Co-simulations of FMUs with 32-bit binaries. Only valid on win64 platform with MSVC toolchain installed.

Option to save source code to FMU, specified as 'on' or 'off'. Set to 'on' to package the source code in the source directory and documentation file, which recompiles the binary files in the documentation directory in the FMU. This option requires Simulink Coder™.

This option has the following limitations:

  • This feature utilizes packNGo function and is subject to its limitations. For a list of its limitations, see packNGo (MATLAB Coder).

  • This feature is not supported for models that contain an FMU block.

  • This feature may pack operating system dependent code.

  • This feature only supports C files. Source code dependencies to other file types are unsupported.

Save location for FMU, specified as a string or character vector. By default, the location is the current working folder.

Example: exportToFMU2CS(model,'SaveDirectory','/tmp/flightcontrol/')

Option to create to create a wrapper-archived project or harness model with dependencies, specified as 'off' or 'project'. Set to 'project' to enable this option.

Specify the names of parameters to be exported as a cell array of character vectors. Argument entry {} exports all the parameters while {''} exports no parameters.

Example: exportToFMU2CS(model, 'ExportedParameters', {''}) exports no parameters

Specify the exported names of the parameters specified using ExportedParameters as a cell array of character vectors. The length of the character vector should be the same as character vector specified for ExportedParameters. If this value is not set, the exported parameters names are the same as the default names specified in the model.

Example: exportToFMU2CS(model, 'ExportedParameters', {'gain1'},'ExportedParameterNames',{'Gain_1'}) exports the parameter gain1 as Gain_1

Specify the names of internal variables to be exported as a cell array of character vectors. Argument entry {} exports all the internal variables while {''} exports none.

Example: exportToFMU2CS(model, 'ExportedInternals', {''}) exports no internal variables

Specify the exported names of the internal variables specified using ExportedInternals as a cell array of character vectors. The length of the character vector should be the same as character vector specified for ExportedInternals. If this value is not set, the exported internal variable names are the same as the default names specified in the model.

Example: exportToFMU2CS(model, 'ExportedInternals', {'var1'},'ExportedInternalNames',{'Var_1'}) exports the internal variable var1 as Var_1

Specify the exported names of the root inports specified as a cell array of character vectors. The length of the character vector should be the same as the number of root input ports. If this value is not set, the exported input names are the same as the default names specified in the model.

Specify the exported names of the root outports specified as a cell array of character vectors. The length of the character vector should be the same as the number of root output ports. If this value is not set, the exported output names are the same as the default names specified in the model.

Enable automatic data type conversion of unsupported FMI data types for inputs, outputs, and internal variables.

Name of the archived project with harness model, specified as a string. This argument must be specified along with the 'ExportContent' argument. By default, the archived project is named modelName_fmu

Destination folder and files to be packaged, specified as a cell array.

Example: exportToFMU2CS(model, 'Package', {'documentation/', {'/local/bouncingBall/index.html','/local/bouncingBall/siteFiles'},... 'resources',{'local/bouncingBall/resources/input.txt'}})

Version History

Introduced in R2020a

collapse all

R2024a: exportToFMU2CS will be removed

exportToFMU2CS function will be removed in a future release. Use exportToFMU instead for exporting your Simulink models to FMU.