Create Projects - MATLAB & Simulink (original) (raw)

Create projects in MATLAB® to organize, manage, and share your work with others. Projects help standardize settings and environments to maintain consistency across different users and operating systems.

What Are Projects?

A project is a scalable environment where you can manage MATLAB and Simulink® files, data files, requirements, reports, spreadsheets, tests, and generated files together in one place.

As a design grows, managing referenced files and dependencies becomes more complicated. Using projects reduces the complexity of managing large folder hierarchies and helps you work and collaborate. You can use projects to:

Create Project from Existing Folder

To create a project from an existing folder, follow these steps.

  1. On the Home tab, click > . Alternatively, click New Project from the Project panel.
    If you do not have the Project panel in the sidebar, add it using the Open more panels button (three-dot icon) in the sidebar.
  2. In the Create Project dialog box, enter a project name, select the existing folder you want to create the project in, and clickOK.
    MATLAB adds all the files and folders to the new project.
    If you select an empty folder, MATLAB creates a blank project. To add files to the project, seeAdd Files to Project.

By default, MATLAB prepopulates the Folder field with the current folder you have open in the Files panel. You can specify the default folder for new project creation in the project preferences. For more information, see Configure Global MATLAB Projects Settings.

Create Project dialog box with project name and folder fields and OK and Cancel buttons below

Project Definition Files

The files in the resources/project or.SimulinkProject folder are project definition files generated when you first create or make changes to your project. Project definition files specify the files added to your project. Project definition files also specify metadata changes such as changes to shortcuts, labels, and project descriptions.

For releases before R2020b - Instructions to change project definition file type

For releases before R2020b, if you want to change the project definition file type from the type selected when the project was created, follow these steps:

  1. On the Home tab, in the Environment section, click Preferences. Select > and in the New Projects section, select one of these options under Project definition files:
    • Use multiple project files – Helps to avoid file conflicts when performing merge on shared projects
    • Use multiple project files (fixed-path length) – Is better if you need to work with long paths
    • Use a single project file (not recommended for source control) – Is faster but is likely to cause merge issues when two users submit changes in the same project to a source control tool
  2. Create a project archive file (.mlproj). For more information, see Share Projects orexport.
  3. Create a new project from the archived project. For more information, seeCreate Projects.

Set Up Project

After you create or open a project, the Project panel opens and shows all files and folders under the project root folder. A pop-out helps you set up the project.

  1. Click Set Up Project to begin setting up your project. The setup guide takes you through the minimal recommended setup, such as updating the project name and description and setting the project path and the startup and shutdown actions.
    The project setup guide dialog box appears every time you open the project. To disable the project setup guide altogether, on theHome tab, in the Environment section, click Settings. In the > section, clear Show the welcome dialog after opening a project.
    The MATLAB layout after a new project creation shows the Project panel open on the left, the Project toolstrip on top, and a pop-out that points to the Project panel.
  2. In Step 1 of 4, you can edit the project name and add a description. Include information you want to share with other project users. Then, clickNext.
  3. In Step 2 of 4, you can choose folders to add to the project path. Adding project folders to the project path ensures that all users of the project can access the files within them. MATLAB adds these folders to the search path when you open the project, and removes them when you close the project.
    To add all the folders in project folder to the project path, clickAdd with Subfolders and then select the root project folder containing all your subfolders.
    After specifying the project path, click the Next button to continue.
    You can edit the project path at anytime in Project Settings. For more information, see Specify Project Path.
    Search Path section in the Project Settings dialog box shows the list of folders on the project path on the left and Add Folder, Add with Subfolders, and Remove buttons on the right.
  4. In Step 3 of 4, you can specify startup and shutdown files. Startup files help you set up the environment for your project. Shutdown files help you clean up the environment when you are done. Use shutdown files to undo the setup that occurs in startup files.
    Use the Add and Remove buttons to manage the startup and shutdown file lists. The files run from the top down. If the order in which the files run is important, use the arrow buttons to move files up or down in the list.
    After specifying the project startup and shutdown tasks, click theNext button to continue.
    You can specify startup and shutdown files at anytime in Project Settings. For more information, see Automate Startup and Shutdown Tasks.
    Task Automation section in the Project Settings dialog box shows the list of startup and shutdown files on the left and Add and Remove buttons on the right.
  5. In Step 4 of 4, for the setup to take effect in your new project, clickFinish Setup.
    Close the dialog box by clicking OK.

Add Files to Project

When you create a blank project, the Project panel shows only the project definition files stored in the resources folder.

To create a new file or folder in the project, in the Project panel, right-click in the white space and select from the available options underNew. MATLAB creates and adds the file or folder to the project.

To add existing files to a project, use one of these options.

To add and remove project files programmatically, use the addFile function.

You might not want to include all files in your project. For example, you might want to exclude derived files in the project root folder, such as code generation files and folders. To determine which files need to be included in your project, seeAnalyze Project Dependencies.

Open Project

To open an existing project, on the Home tab, click and browse to an existing project.prj file. Alternatively, in the Files panel, double-click the project .prj file.

Note

To avoid conflicts, you can have only one project open at a time. If you open another project, any currently open project closes.

To open a recent project, use any of these methods:

Unsafe Content Warning

When you open a project from an unknown source for the first time, MATLAB warns that the content might be unsafe. Projects from unknown sources include projects you clone from a remote repository, download, or receive as an archive.

A project can be configured to execute code automatically on startup and change the MATLAB path. To protect yourself from malicious attacks, make sure you trust the sender or the author of the project before you open the project.

After you open a project for the first time, MATLAB remembers your choice and does not show a warning for the same project again. If you open and trust a project that references other projects, MATLAB trusts all projects in the hierarchy.

To disable these warnings altogether, on the Home tab, in theEnvironment section, click Settings. In the > section, clear Warn when opening projects from unknown sources.

Other Ways to Create Projects

There are several alternative ways to create a project. You can:

Create Project from Archived Project

Some projects are shared as archived projects. An archived project is useful for sharing with users who do not have access to a connected source control tool. To view and edit the contents of an archived project, create a new project from the archived project.

To create a new project from an archived project, follow these steps.

  1. In the Files panel, double-click the MLPROJ archived project file.
  2. In the Extract Project to dialog box, specify the location for the new project and click Select Folder. For example,C:\_`WorkSpace\myNewProject`_.

Alternatively, in the Files panel, right-click the MLPROJ archived project file and select Extract here.

The new project opens automatically. The current folder,C:\_`WorkSpace\myNewProject`_, contains the imported project folders and files.

If the archived project contains a referenced project, MATLAB also imports the referenced project and stores it in a folder relative to the main project folder. For example,C:\_`WorkSpace\ReferencedProject`_.

Create Project from Dependency Graph

When you run a dependency analysis for a folder or a file, you can create a project that includes all dependencies from the dependency graph.

  1. Open the Dependency Analyzer. In MATLAB, on the Apps tab, underMATLAB, click the Dependency Analyzer icon .
  2. Select the files or folder you want to analyze using theOpen Folder and the Open Files buttons.
  3. To create a project from all the files displayed in the dependency graph, in the Dependency Analyzer toolstrip, in theExport section, click Create Project. In the Create Project window, click OK. The Dependency Analyzer creates a project and reloads the graph.
    You can also create a project from a subset of files in the graph. Select the files, then click Create Project. The Dependency Analyzer includes the selected files and all their dependencies in the project.

See Also

openProject | matlab.project.createProject | matlab.project.extractProject | addFile | addFolderIncludingChildFiles | addPath | addStartupFile | addShutdownFile

See Also

Dependency Analyzer

Topics

External Websites