Converting from MDL to SLX Model File Format in a Simulink Project
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.
Open the Airframe Example Project and Save the MDL Files as 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 "/private/tmp/BR2017bd_681905_31616/bml.batserve.002620/work/MATLAB/projects/slexamples/airframe2" Initializing: Project Path Setting up working folders Identifying shadowed project files Building with 'Xcode with Clang'. MEX completed successfully.
Find All MDL Files in This Project and Convert to SLX
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 = simulinkproject; 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
Project File Status
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.
Run the Project Checks
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.