This example shows how the Simulink® Project's checks support upgrading from MDL format model files to SLX format. The default file format for Simulink models in R2012b and subsequent releases is SLX.
Run the following commands to create and open a working copy of the "sldemo_slproject_airframe" example.
Simulink.ModelManagement.Project.projectDemo('airframe', 'svn'); rebuild_s_functions('no_progress_dialog');
Creating sandbox for project. Created example files in "/tmp/bml.batserve.048566/work/projects/slexamples/airframe2" Initializing: Project Path Identifying shadowed project files Running: /tmp/bml.batserve.048566/work/projects/slexamples/airframe2/utilities/set_up_project.m Building with 'gcc'. MEX completed successfully.
Click the Project Files node to view all the files in the project. Look in the models folder to see that this project contains models saved in MDL format.
Use the Simulink Project API to find all the files in this project that are saved in MDL format, and resave them as SLX format.
project = slproject.getCurrentProject(); allProjectFiles = project.Files; for fileIndex = 1:numel(allProjectFiles) projectFile = allProjectFiles(fileIndex); [folder, name, ext] = fileparts(projectFile.Path); if strcmp(ext, '.mdl') % This is a MDL file. Load it and then save as an SLX file. mdlModel = fullfile(folder, [name, ext]); slxModel = fullfile(folder, [name '.slx']); load_system(mdlModel); % Save a new copy of this file in SLX format: save_system(name, slxModel); close_system(name,0); end end
Select the All Files view after clicking on the Files node to view all the files in the project. Look in the models folder to see that there are now missing files. This is because the original .mdl files have been renamed as .mdl.r20XXX backup files (where r20XXX is the name of the release in which those files were last modified, for example .mdl.r2012b), and the newly created .slx files are not yet in the project.
To fix this, run the Project Checks by clicking Check Project in the Simulink Project tab.
Click "Fix" to resolve the problem.
The project checks rerun automatically to verify that the problem is resolved.
Click the Modified Files node of the project to see that the newly created SLX files have now been added to the project, and the original MDL files are scheduled for removal.
After the SLX files have been committed, the revisions of the original MDL file will also be presented when viewing past revisions of the SLX file in the Simulink Project.