(Not recommended) Get project file by name
Open the airframe project and create a project object.
sldemo_slproject_airframe; proj = simulinkproject;
findFile to get a file by name. You need to know the path
if it is inside subfolders under the project root.
myfile = findFile(proj,'models/AnalogControl.slx')
myfile = ProjectFile with properties: Path: [1x86 char] Labels: [1x1 slproject.Label] Revision: '2' SourceControlStatus: Unmodified
Alternatively, you can examine files by index. Get the first file.
file = proj.Files(1);
Find out what you can do with the file.
Methods for class slproject.ProjectFile: addLabel removeLabel findLabel
Project, specified as a project object. Use
simulinkproject to create a project object to manipulate a project at the
fileorfolder— Path of file or folder
Path of the file or folder to find relative to the project root folder, specified as a character vector, string, or array. Files must include any subfolders under the project root and the file extension. The file or folder must be within the root folder.
file— Project file
Project file, returned as a file object that you can query or modify.
Not recommended starting in R2019a
Starting in R2019a, instead of
simulinkproject and related functions,
functions in MATLAB®. The Simulink® project API will continue to be supported, but, after R2019a, new features
might be available only if you use the new MATLAB project API. There are no plans to remove the Simulink project API at this time.
The new MATLAB project API is part of the R2019a functionality enabling you to use projects in MATLAB, with or without Simulink. You can now share projects with users who do not have Simulink.