MATLAB Examples

Upgrade Simulink Models Using a Simulink Project

Easily upgrade all the models in your project either programmatically or using the Upgrade Project tool in Simulink Project.


Setting Up the Example Files and Opening Simulink Project

1. Run the following commands to create and open a working copy of the project files.

Simulink.ModelManagement.Project.projectDemo('airframe', 'svn');
Starting: Simulink
Initializing: Project Path
Setting up working folders
Identifying shadowed project files
Building with 'Microsoft Visual C++ 2015 (C)'.
MEX completed successfully.

The project example copies files to a new folder so that you can edit them and use them under SVN version control. Placing your files under version control lets you compare the upgraded model files with the original versions.

Programmatic Upgrade Using Upgrade Advisor

2. Click the Files node in the Project user interface and expand the "utilities" folder. Right-click the file "upgrade_project.m" and select "Run".

The upgrade_project function uses the project dependency analysis to find the top-level models in the project. When first opened, this example project has no previous dependency analysis results, and so dependency analysis is run.

The upgrade_project function runs the Upgrade Advisor on the top-level models in this project. This can take a few minutes. You can see progress information in the MATLAB command window. When the upgrade completes, view the report summarizing the upgrade tasks performed.

Add New SLX Files to the Project

3. Click the Modified Files node to see the files in your sandbox that were modified by the Upgrade Advisor. Look in the models folder to see that some MDL files show the status "Missing". This is because they have been upgraded to SLX files. To fix this, run the Project Checks by clicking Run Checks > Check Project in the Simulink Project tab.

Click "Fix" to resolve the problem.

To complete the fixes, click Yes. The project checks rerun automatically to verify that the problem is resolved. To learn more about how project checks support upgrading from MDL format model files to SLX format, run the example "sldemo_slproject_convert_to_SLX".

Review the Upgrades

You can use the comparison tool from the project to understand the changes you have made, perhaps as part of a peer-review process.

4. Right-click a file in the Modified File view and select "Compare to Ancestor".

This opens a comparison using the MATLAB Comparison Tool, comparing the modified version of the file in your sandbox against its ancestor stored in your version control tool. If you select a Simulink model this runs a Simulink® Model Comparison.

Automatically Upgrade All Project Models and MATLAB Code at Once

Upgrade all models and MATLAB code in your Simulink project to the latest release using a simple workflow. The Upgrade Project tool can apply fixes automatically when possible, upgrade all model hierarchies in the project at once, and produce a report. You do not need to open the Upgrade Advisor.

5. In the Simulink Project tab click Run Checks > Upgrade.

This loads the upgrade advisor checks and runs a dependency analysis on your project to ensure the project hierarchy is handled correctly.

Click Upgrade to run all upgrade checks on all models, libraries and MATLAB code in your project. If any check fails and there is a fix available, the project automatically applies the fix and runs the relevant checks again to ensure they now pass.

Inspect the results of the upgrade in the report.

Further Information

Simulink Project documentation Simulink Upgrade Advisor documentation Upgrade All Project Models documentation