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 any file or folder under the project root 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: [1x8 slproject.Shortcut]
      ProjectPath: [1x7 slproject.PathFolder]
ProjectReferences: [1x0 slproject.ProjectReference]
            Files: [1x30 slproject.ProjectFile]
       RootFolder: 'C:\Work\Simulink\Projects\slexamples\airframe'

Find Project Commands

Find out what you can do with your project.

methods(proj)
Methods for class slproject.ProjectManager:

addFile                       findCategory        
addFolderIncludingChildFiles  findFile            
close                         isLoaded            
createCategory                listModifiedFiles   
export                        refreshSourceControl


reload
removeCategory
removeFile     

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 = 

  1x30 ProjectFile array with properties:

    Path
    Labels
    Revision
    SourceControlStatus

Use indexing to access files in this list. The following command gets file number 13. Each file has properties describing its path, attached labels, and source control information.

proj.Files(13)
ans = 

  ProjectFile with properties:

      Path: 'C:\Work\slexamples\airframe\models\AnalogControl.mdl'
             Labels: [1x1 slproject.Label]
           Revision: '2'
SourceControlStatus: Unmodified

Examine the labels of the 13th file.

proj.Files(13).Labels
ans = 

  Label with properties:

File: 'C:\Work\slexamples\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:\Work\slexamples\\airframe\models\AnalogControl.mdl'
    Labels: [1x1 slproject.Label]
  Revision: '2'
SourceControlStatus: Unmodified

Find out what you can do with the file.

methods(myfile)
Methods for class slproject.ProjectFile:

addLabel
findLabel
removeLabel

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, or any subfolder or file under your project root, 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 PropertyDescription
NameProject name
CategoriesCategories of project labels
ShortcutsShortcut files in project
ProjectPath

Folders that the project puts on the MATLAB path 

ProjectReferencesFolders that contain referenced projects 
FilesPaths and names of project files
RootFolderFull path to project root folder

More About

collapse all

Tips

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

Introduced in R2012a

Was this topic helpful?