This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


(Not recommended) Get project file by name

simulinkproject is not recommended. Use currentProject or openProject instead. For more information, see Compatibility Considerations.


file = findFile(proj,fileorfolder)



file = findFile(proj,fileorfolder) returns a specific project file by name. You need to get a file before you can query labels, or use addLabel or removeLabel.


collapse all

Open the airframe project and create a project object.

proj = simulinkproject;

Use 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.mdl')
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          

Input Arguments

collapse all

Project, specified as a project object. Use simulinkproject to create a project object to manipulate a project at the command line.

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.

Example: ‘models/myModelName.slx’

Output Arguments

collapse all

Project file, returned as a file object that you can query or modify.

Compatibility Considerations

expand all

Not recommended starting in R2019a

Introduced in R2013a