Main Content

Get Started with MATLAB Projects

This example shows how to use an existing project to manage the files within your design. You can automate startup and shutdown tasks, add shortcuts for common tasks, run checks, upgrade project files, analyze project dependencies, and share your project.

As a design grows, managing referenced files and dependencies becomes more complicated. Projects help you organize large hierarchies by finding required files, managing and sharing files and settings, and interacting with source control. Download and open the example project using the MATLAB® command provided by the Copy Command button.

This example project is not under source control. As a result, essential tools needed in a collaborative environment are not available for use, for example, comparing files to their ancestors, comparing revisions, and resolving conflicts. To explore example projects under Git™ and SVN source control, see Using a Project with Git or Using a Project with SVN instead.

The MATLAB desktop shows the Project panel with the project open on the left, the Project toolstrip on top, the Command Window in the middle, and the Project Issues panel on the right.

For instructions on how to create an new project from scratch, see Create Projects.

Explore Project

The Project panel shows all files in the project root folder. To view only the files that have the status In project, right-click the white space and select Filter > Show Only Project Files.

Use the Status column to determine the status of the files and folder in the project root folder, such as In project, Not in project, On project path, and Project shortcut.

Specify Project Details, Startup Folder, and Derived Files Folders

On the Project tab, in the Environment section, click Settings.

  • In the Details section, edit the project name or add a description. You can also view the Project root folder.

  • In the Startup Folder section, view or edit the Startup Folder. By default, this folder is set to the project root. When you open the project, the current working folder changes to the project root folder. You can specify a different startup folder or click Clear.

  • In the Simulink section, view or edit the Simulation cache folder and Code generation folder.

To change the default project root for new projects, on the MATLAB Home tab, in the Environment section, click Settings. Select MATLAB > Project and edit the selection in the New Projects section.

Manage Project Path

When you open your project, MATLAB adds the project path to the MATLAB search path. When you close your project, MATLAB removes the project path from the MATLAB search path.

To add a folder to the project path, on the Project tab, in the Environment section, click Settings. Then, in the Search Path section, click Add Folder and select the folder that you want to add. To add a folder and all of its subfolders, click Add with Subfolders instead.

To remove a folder from the project path, select the folder from the displayed list and click Remove.

You also can add or remove a folder from the Project panel. Right-click the folder, select Add to Project Path or Remove from Project Path.

You must add project files to the project path to ensure that the Dependency Analyzer detects all project files.

Automate Startup and Shutdown Tasks

You can set project files, such as MATLAB scripts and Simulink® models, to run, open, or close when the project opens or closes. On the Project tab, in the Environment section, click Settings. Then, in the Task Automation section, in the Startup files or Shutdown files pane, click Add and select a file in the browser.

To stop a file from running at startup or shutdown, select the file and click Remove. The files run from the top down. If the order in which the files are run is important, use the Move Up and Move Down buttons to reorder the files.

You can specify additional Simulink® environment options to run on project startup and shutdown in the Simulink section of Project Settings.

  • To start Simulink® when you open the project, select Start Simulink before opening this project.

  • To run sl_customization files on project startup and shutdown, select Refresh Simulink customizations after opening or closing this project.

Project Shortcuts for Common Tasks

Create project shortcuts for common tasks to make it easy to find and access important files and operations. For example, find and open top models, run code, and simulate models.

On the Project tab, in the Shortcuts gallery, this example project has shortcuts for the top-level model, a utility function to rebuild S-functions, and a design description document.

  • To open the root model for this project, click the shortcut F14 Model.

  • To generate the S-function, click the shortcut Rebuild Project's S-functions.

  • To create a new shortcut for a project file, expand the Shortcuts gallery and click New Shortcut.

  • To edit a shortcut, right-click a shortcut and select Edit Shortcut.

Analyze Project Dependencies

Use the Dependency Analyzer to investigate dependencies visually and explore the structure of your project. On the Project tab, click the down arrow to expand the Tools gallery. Under Apps, click Dependency Analyzer.

The Dependency Analyzer summarizes the results in the pane on the right. It lists the names of the used Products and Add-Ons. It detects problems, such as missing files, files not in the project, unsaved changes, and out-of-date derived files. In this example, the analyzer identifies a File not in project and tags it with a warning sign.

To highlight problem files, in the Problems section, point to the problem message and click the magnifying glass. In this example, the timesthree.mexw64 file is required by the project but is not part of it. Right-click timesthree.mexw64 and select Add to Project or Hide Warnings. Next time you run the dependency analysis, the analyzer will not mark this file as a problem.

Perform an impact analysis on a selected file.

An impact analysis shows you how a change affects other files before you make the change. For example, to find required files for timesthree.mexw64 to run properly, right-click timesthree.mexw64 and select Find Required. To find how changes to timesthree.mexw64 impact files, right-click timesthree.mexw64 and select Find Impacted.

Upgrade Project Files

You can easily upgrade all models, libraries, and MATLAB code files in your project to the latest release. On the Project tab, click the down arrow to expand the Tools gallery. Under Apps, click Upgrade Project.

To upgrade all files, run all checks, and apply fixes automatically where possible, click Upgrade. For more information, see Check for Compatibility Issues and Upgrade Simulink Models Using Project Upgrade.

Share Project

Before sharing projects with other users, use the Dependency Analyzer to find required files and products.

On the Project tab, select Share and explore the different sharing options.

You can share your project as an archive and send it by email.

  1. On the Project tab, select Share > Archive.

  2. Export the whole project or just a part of it using Export profile. If you decide to exclude files from your project, use the Dependency Analyzer to examine the impact of excluding a file on the project.

  3. If you have referenced projects and want to export the referenced project files, then select the Include referenced projects check box.

You can also share your project and make it publicly available on GitHub® which adds Git source control to the open project. For more information, see Share Projects.

See Also

Topics