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.

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.

example

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

Examples

collapse all

Open the Simulink Project Tool.

simulinkproject

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 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')

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'
      Information: [1×1 slproject.Information]
     Dependencies: [1×1 slproject.Dependencies]
        Shortcuts: [1×9 slproject.Shortcut]
      ProjectPath: [1×7 slproject.PathFolder]
ProjectReferences: [1×0 slproject.ProjectReference]
       Categories: [1×1 slproject.Category]
            Files: [1×33 slproject.ProjectFile]
       RootFolder: 'C:\slexamples\airframe11'

Find out what you can do with your project.

methods(proj)
Methods for class slproject.ProjectManager:


addFile                       createCategory  
addFolderIncludingChildFiles  export
close                         findCategory

findFile                      refreshSourceControl
isLoaded                      reload 
listModifiedFiles             removeCategory

removeFile 

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

Examine the project files.

files = proj.Files
files = 

  1x33 ProjectFile array with properties:

    Path
    Labels
    Revision
    SourceControlStatus

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

proj.Files(14)
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 14th file.

proj.Files(14).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

Update the file dependencies.

update(proj.Dependencies)

The project runs a dependency analysis to update the known dependencies between project files.

For more information on working with project files, including modified files and dependencies, see Automate Project Management Tasks.

Related Examples

Input Arguments

collapse all

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 character vector.

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

Example: 'C:/projects/project1/'

Output Arguments

collapse all

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
InformationInformation about the project such as the description, source control integration, and repository location.
DependenciesDependencies between project files in a MATLAB digraph object
ShortcutsShortcut files in project
ProjectPath

Folders that the project puts on the MATLAB path 

ProjectReferencesFolders that contain referenced projects. Contains read-only project objects for referenced projects. 
CategoriesCategories of project labels
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?