findFile

Get Simulink Project file by name

Syntax

  • file = findFile(proj,fileName) example

Description

example

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

Examples

expand all

Find a File By Name

Open the airframe project and create a project object.

sldemo_slproject_airframe;
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]

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(file)
Methods for class slproject.ProjectFile:

ProjectFile          addLabel    removeLabel  findLabel          

Alternatively, you can find project files by their labels using findLabel.

Input Arguments

expand all

proj — Projectproject

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

fileName — Path of filestring

Path of the file to find, including any subfolders under the project root, specified as a string.

Output Arguments

expand all

file — Project filefile object

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

Was this topic helpful?