Documentation

simulinkproject

Open Simulink Project and get project object

Syntax

  • proj = simulinkproject
    example
  • proj = simulinkproject(projectPath)
    example

Description

example

simulinkproject opens Simulink® Project or brings focus to the tool if it is already open. After you open the tool, you can create new projects or access recent projects using the Simulink Project tab.

example

simulinkproject(projectPath) opens the Simulink project specified by the .prj file or folder in projectPath and gives focus to Simulink Project.

example

proj = simulinkproject returns a project object proj you can use to manipulate the project at the command line. You need to get a project object before you can use any of the other project functions.

If you want to avoid giving focus to Simulink Project in your startup script, specify an output argument.

example

proj = simulinkproject(projectPath) opens the Simulink project specified by projectPath and returns a project object.

To avoid your startup script opening windows that take focus away from the MATLAB® Desktop, use start_simulink instead of the simulink function, and use simulinkproject with an output argument instead of uiopen.

Examples

collapse all

Open Simulink Project Tool

Open the Simulink Project Tool.

simulinkproject

Open a Simulink Project

Specify either the .prj file path or the folder that contains your .SimulinkProject folder and .prj file. The project opens and brings focus to Simulink Project.

simulinkproject('C:/projects/project1/')

Open a Simulink Project and Get a Project Object

Open a specified project and get a project object to manipulate the project at the command line. To avoid your startup script opening windows that take focus away from the MATLAB Desktop, use start_simulink instead of the simulink function, and use simulinkproject with an output argument instead of uiopen. If you use uiopen(myproject.prj) this calls simulinkproject with no output argument and gives focus to Simulink Project.

start_simulink
proj = simulinkproject('C:/projects/project1/myproject.prj')

Get Airframe Example Project

Open the Airframe project and create a project object to manipulate and explore the project at the command line.

sldemo_slproject_airframe
proj = simulinkproject
proj = 

  ProjectManager with properties:

             Name: 'Simulink Project Airframe Example'
       Categories: [1x1 slproject.Category]
        Shortcuts: [1x10 slproject.Shortcut]
      ProjectPath: [1x6 slproject.PathFolder]
ProjectReferences: [1x1 slproject.ProjectReference]
            Files: [1x26 slproject.ProjectFile]
       RootFolder: 'C:\Work\temp\slexamples\airframe'

Find Project Commands

Find out what you can do with your project.

methods(proj)
Methods for class slproject.ProjectManager:

addFile   export   reload
addFolderIncludingChildFiles findCategory
removeCategory
close  findFile  removeFile
createCategory  isLoaded        

Examine Project Properties Programmatically

After you get a project object using the simulinkproject function, you can examine project properties.

Examine the project files.

files = proj.Files
files = 

  1x26 ProjectFile array with properties:

    Path
    Labels

Use indexing to access files in this list. The following command gets file number 8. Each file has two properties describing its path and attached labels.

proj.Files(8)
ans = 

  ProjectFile with properties:

      Path: 'C:\Temp\project1\airframe\models\AnalogControl.mdl'
    Labels: [1x1 slproject.Label]

Examine the labels of the eighth file.

proj.Files(8).Labels
ans = 

  Label with properties:

File: 'C:\Temp\project1\airframe\models\AnalogControl.mdl'
            Data: []
        DataType: 'none'
            Name: 'Design'
    CategoryName: 'Classification'

Get a particular file by name.

myfile = findFile(proj,'models/AnalogControl.mdl')
myfile = 

  ProjectFile with properties:

      Path:  'C:\Temp\project1\airframe\models\AnalogControl.mdl'
    Labels: [1x1 slproject.Label]

Find out what you can do with the file.

methods(myfile)
Methods for class slproject.ProjectFile:

addLabel
removeLabel
findLabel

Related Examples

Input Arguments

collapse all

projectPath — Full path to project file or folderstring

Full path to project .prj file, or the path to the project root folder, specified as a string.

Example: 'C:/projects/project1/myProject.prj'

Example: 'C:/projects/project1/'

Output Arguments

collapse all

proj — Projectproject object

Project, returned as a project object. Use the project object to manipulate the currently open Simulink project at the command line.

Properties of proj output argument.

Project PropertyDescriptionValue
NameProject nameString
CategoriesCategories of project labelsCell array of strings
ShortcutsShortcut files in projectCell array of strings
ProjectPath

Folders that the project puts on the MATLAB path 

Cell array of strings
ProjectReferencesFolders that contain referenced projects Cell array of strings
FilesPaths and names of project filesCell array of strings
RootFolderFull path to project root folderString

More About

expand all

Tips

Alternatively, you can use slproject.loadProject to load a project, and slproject.getCurrentProject to get a project object. Use simulinkproject to open projects and explore projects interactively. Use slproject.getCurrentProject and slproject.loadProject for project automation scripts.

Introduced in R2012a

Was this topic helpful?