Main Content

simulinkproject

(Not recommended) Open project and get project object

simulinkproject is not recommended. Use currentProject or openProject instead. For more information, see Version History.

Description

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

example

simulinkproject(projectPath) opens the project specified by any file or folder under the project root in projectPath and gives focus to the 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.

example

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

example

Examples

collapse all

Open the 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 the 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 the 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.

openExample('simulink/AirframeProjectExample')
proj = simulinkproject
proj = 

  ProjectManager with properties:

             Name: 'Simulink Project Airframe Example'
      Information: [1x1 slproject.Information]
     Dependencies: [1x1 slproject.Dependencies]
       Categories: [1×1 slproject.Category]
            Files: [1×31 slproject.ProjectFile]
        Shortcuts: [1×7 slproject.Shortcut]
      ProjectPath: [1×7 slproject.PathFolder]
ProjectReferences: [1×0 slproject.ProjectReference]
     StartupFiles: [1×0 slproject.StartupFile]
    ShutdownFiles: [1×0 slproject.ShutdownFile]
       RootFolder: 'C:\slexamples\airframe11'

Find out what you can do with your project.

methods(proj)
Methods for class slproject.ProjectManager:


addFile                       
addFolderIncludingChildFiles  
addPath                       
addReference                  
addShortcut                   
addShutdownFile                    
addStartupFile
close                         
createCategory                
export                        
findCategory                  
findFile                      
isLoaded                      
listModifiedFiles             
listRequiredFiles             
refreshSourceControl          
reload                        
removeCategory                
removeFile                    
removePath                    
removeReference               
removeShortcut
removeShutdownFile
RemoveStartupFile   

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

Examine the project files.

files = proj.Files
files = 

  1x31 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(15)
ans = 

  ProjectFile with properties:

      Path: 'C:\slexamples\airframe24\models\DigitalControl.slx'
                 Labels: [1x1 slproject.Label]
               Revision: '2'
    SourceControlStatus: Unmodified

Examine the labels of the file.

proj.Files(15).Labels
ans = 

  Label with properties:

File: 'C:\slexamples\airframe24\models\DigitalControl.slx'
        DataType: 'none'
            Data: []
            Name: 'Design'
    CategoryName: 'Classification'

Get a particular file by name.

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

  ProjectFile with properties:

  Path: 'C:\slexamples\airframe24\models\AnalogControl.slx'
                 Labels: [1×1 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 Tasks Using Scripts.

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 project at the command line.

Properties of proj output argument.

Project PropertyDescription
CategoriesCategories of project labels
DependenciesDependencies between project files in a MATLAB digraph object
FilesPaths and names of project files
InformationInformation about the project such as the description, source control integration, repository location, and whether it is a top-level project
NameProject name
ProjectPath

Folders that the project puts on the MATLAB path 

ProjectReferencesFolders that contain referenced projects. Contains read-only project objects for referenced projects. 
RootFolderFull path to project root folder
ShortcutsAn array of the shortcuts in this project
ShutdownFilesAn array of the shutdown files in this project
StartupFilesAn array of the startup files in this project

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.

Version History

Introduced in R2012a

collapse all

R2019a: Simulink project API is not recommended

Starting in R2019a, instead of simulinkproject and related functions, use the currentProject or openProject functions in MATLAB. The Simulink® project API will continue to be supported, but, after R2019a, new features will be available only if you use the new MATLAB project API. There are no plans to remove the Simulink project API at this time.

You can continue to use simulinkproject and related functions listed in methods(simulinkproject). New functions added after R2019a, such as runChecks and listImpactedFiles, do not work with simulinkproject. Use currentProject instead.

The new MATLAB project API is part of the R2019a functionality enabling you to use projects in MATLAB, with or without Simulink. You can now share projects with users who do not have Simulink.