Main Content

Simulink.exportToVersion

R2026b

Export model, library, or project for use in previous version of Simulink

Description

exported_file = Simulink.exportToVersion(modelname,target_filename,version) exports the specified model or library to the specified version of Simulink® in a format that version can load.

If the system contains functionality not supported by the specified Simulink version, the command removes the functionality and replaces any unsupported blocks with empty masked subsystem blocks colored yellow. As a result, the converted system may generate different results.

The save_system ExportToVersion legacy option is supported for this functionality.

example

exported_file = Simulink.exportToVersion(modelname,target_filename,version,Name=Value) specifies additional options as one or more name-value arguments.

example

exported_project = Simulink.exportToVersion(proj,zipfilename,version) exports the project proj to a ZIP file zipfilename in a format that the specified previous Simulink version can load. If the project contains requirements link files or requirements files, Simulink.exportToVersion updates the links to point to the newly exported files.

exported_project = Simulink.exportToVersion(proj,zipfilename,version,Name=Value) exports the project with the criteria specified by one or more Name=Value arguments. You can use this syntax to export referenced projects and missing files.

Releases prior to R2025a do not support filenames that exceed 63 characters. If you attempt to export a project that contains filenames exceeding 63 characters to a release prior to R2025a, the function lists the project files with long names. Shorten the names and replace all references to the filename in the project before exporting to a previous release.

example

Examples

collapse all

Export the current top-level system to R2022b.

 Simulink.exportToVersion(bdroot,"mymodel.slx","R2022b");

Export the current top-level system to R2023b, replacing links to library blocks with copies of the library blocks in the saved file.

Simulink.exportToVersion(bdroot,"mymodel.slx",...
                         "R2023b",BreakUserLinks=true);

Export the current top-level project to R2023a.

openExample('simulink/AirframeProjectWithReferencesExample')
proj = currentProject;
Simulink.exportToVersion(proj,"myzipfilename","R2023a");

Export the current top-level project and all referenced projects to R2024a.

Simulink.exportToVersion(proj,"myzipfilename","R2024a",IncludeReferences=true);

Input Arguments

collapse all

Name of model to export, specified as a string or character vector without file extension. The model must be loaded and unmodified. The target file must be different than the model file.

Data Types: string | character vector

Exported file name, specified as a string or character vector. The target file must be different than the model file.

Example: "myExportedModel.slx"

Project to export, specified as a matlab.project.Project object. Use currentProject to create a project object from the currently loaded project.

Name of ZIP file containing the exported project, specified as a string or character vector.

Example: "myExportedProject.zip"

MATLAB release name, case-insensitive, specified as a string or character vector. The MATLAB release name specifies a previous Simulink version. Simulink.exportToVersion exports the system to a format that the specified previous Simulink version can load. You can export your models up to 7 years of previous releases. You cannot export to your current version.

You can specify the model file format as SLX or MDL using the suffix _MDL or _SLX. If you do not specify a format, you export your default model file format. You cannot specify the model files format when exporting a project.

Example: "R2015B"

Data Types: string | character vector

Name-Value Arguments

collapse all

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.

Example: Simulink.exportToVersion(bdroot,"mymodel.slx",... "R2014b",BreakUserLinks=true);

Option to display either any output prompt or message in a dialog box or only messages at the command line, specified as a logical value. For example, choose to display prompts to make files writable or messages about exported versions. To display prompts, specify true or "on". To hide prompts, specify false or "off".

Data Types: string | character vector | logical

Option to export referenced projects to a previous release, specified as a logical value. To turn the option on, specify true or 1. To turn the option off, specify false or 0.

When the option is turned on, Simulink.exportToVersion exports the top-level and all referenced projects to a previous release, and includes the references in the ZIP file. Extracting the ZIP file creates a copy of the referenced projects and links them to the top-level project.

When the option is turned off, Simulink.exportToVersion only exports the top-level project to a previous release. Simulink.exportToVersion preserves the existing absolute and relative link to the references. For a working project on extraction, the references must be at the same absolute and relative paths.

The argument is ignored if the project does not have references.

Data Types: logical

Option to ignore missing project files when exporting projects to a previous release, specified as a logical value. To turn the option on, specify true or 1. To turn the option off, specify false or 0.

When the option is turned on, Simulink.exportToVersion does not issue error related to missing project files during the export process.

When the option is turned off, Simulink.exportToVersion issues errors when detecting missing files in the project.

Data Types: logical

Output Arguments

collapse all

File path of the exported file, returned as a character vector.

Data Types: character vector

File path of the ZIP file containing the exported project, returned as a character vector.

Data Types: character vector

Limitations

  • Simulink.exportToVersion does not support exporting external test harnesses to previous releases.

    • For models with external test harnesses, Simulink.exportToVersion automatically converts them to internal test harnesses.

    • For projects containing models with external test harnesses, Simulink.exportToVersion exports the projects and reports the test harnesses as missing files.

  • Simulink.exportToVersion does not support exporting configurations stored in a data dictionary or a referenced dictionary. As a result, the exported data dictionary does not contain configurations stored in the original data dictionary.

Version History

Introduced in R2016a

expand all