Contenido principal

Simulink.VariantManager.exportVariantConfigurations

R2026b

Export variant configurations object to file

Since R2026b

Description

Simulink.VariantManager.exportVariantConfigurations(modelName,FileName=fileName) exports the Simulink.VariantConfigurations object associated with model modelName to the file specified by fileName. Supported file formats are .mat and .m. If no file extension is specified, the function defaults to .m.

example

Examples

collapse all

Load a model that has a variant configurations object attached.

load_system("myModel");

Export the variant configurations object to a MAT file.

Simulink.VariantManager.exportVariantConfigurations("myModel", ...
    FileName="exportedVCD.mat");

Load the exported MAT file and access the variant configurations object.

data = load("exportedVCD.mat");
vcdoName = get_param("myModel","VariantConfigurationObject");
varConfigs = data.(vcdoName)

Load a model that has a variant configurations object attached.

load_system("myModel");

Export the variant configurations object to a MATLAB® script. If no extension is specified, the function defaults to .m.

Simulink.VariantManager.exportVariantConfigurations("myModel", ...
    FileName="exportedVCD");

Run the exported script to recreate the variant configurations object in the workspace.

run("exportedVCD.m");

Input Arguments

collapse all

Name of the model, specified as a character vector or string scalar. The model must be loaded before calling this function, and the model must have a variant configurations object associated with it.

Example: "slexVariantManagerOverview"

Output filename or path, specified as a character vector or string scalar. The filename must be a valid MATLAB identifier.

Supported file extensions:

  • .m — Export a MATLAB script that recreates the variant configurations object when run.

  • .mat — Export the variant configurations object to a MAT file.

If no extension is specified, the function defaults to .m. If no directory path is specified, the function saves the file in the current folder.

Example: "exportedVCD.mat"

Tips

To recreate the exported variant configurations object, run the exported .m script or load the exported .mat file using the load function.

Version History

Introduced in R2026b