Main Content

Simulink.exportToVersion

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

Description

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

If the system contains functionality not supported by the specified Simulink software 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 option is a legacy option for this functionality that is also supported.

example

exported_file = Simulink.exportToVersion(modelname,target_filename,version,Name,Value) specifies additional options as one or more name-value pair 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.

example

exported_project = Simulink.exportToVersion(proj,zipfilename,version,exportReferencedProjects) exports the top-level project proj and all referenced projects to a ZIP file zipfilename in a format that the specified previous Simulink version can load.

example

Examples

collapse all

Get the current top-level system and export it.

 Simulink.exportToVersion(bdroot,'mymodel.slx','R2014b');

Get the current top-level system and export it, replacing links to library blocks with copies of the library blocks in the saved file.

Simulink.exportToVersion(bdroot,'mymodel.slx',...
                         'R2014b','BreakUserLinks',true);

Get the current top-level project and export it.

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

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

Simulink.exportToVersion(proj,'myzipfilename','R2019a',true);

Input Arguments

collapse all

Model to export, specified as a character vector or string scalar, without any file extension. The model must be loaded and unmodified. The target file must not be the same as the model file.

Data Types: char | string

Exported file name, specified as a character vector or string scalar. The target file must not be the same as the model file.

Example: 'mymodel.slx'

Data Types: char | string

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

ZIP file name containing the exported project, specified as a character vector or string scalar.

Example: 'myzipfile.zip'

Data Types: char | string

MATLAB case-insensitive release name, specified as a character vector or string scalar. 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 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: char | string

(Optional) Export referenced projects to a previous release, specified as true or false.

If true, 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.

If false, 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.

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: 'AllowPrompt','off'

Allow prompt or message dialog box, specified by a logical value that indicates whether to display any output prompt or message in a dialog box or only messages at the command line. For example, prompts to make files writable, or messages about exported versions. If you want to allow prompts, then set to true. or on.

Output Arguments

collapse all

Path of the exported file, returned in the format that the specified previous Simulink version can load.

Path of the ZIP file containing the exported project, returned in the format that the specified previous Simulink version can load.

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.

Version History

Introduced in R2016a