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.
This project example 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 use available source control integration in MATLAB® such as Git™ and SVN, see Using a Project with Git or Using a Project with SVN.
To use an external source control with project, put the project folder under the source control of choice and customize it to use the MATLAB® Comparison Tool for diff and merge. For more information, see Customize External Source Control to Use MATLAB for Diff and Merge.
Set Up Example Files and Open Project
Create and open a working copy of the project example files. MATLAB® copies the files to an example folder so that you can edit them.
Building with 'MinGW64 Compiler (C)'. MEX completed successfully.
Manage Project Path
When you open your project, MATLAB adds the project path to the MATLAB search path before applying startup shortcuts.
When you close your project, MATLAB removes the project path from the MATLAB search path after applying shutdown shortcuts.
To add or remove folders to the project path, on the Project tab, in the Environment section, click Project Path.
To add a folder to the project path, click Add Folder. If you want to add a folder and its subfolders, click Add with Subfolders instead. Then, use the Open dialog box to add the new folder.
To remove a folder from the project path, from the display list, select the folder. Then, click Remove.
You must add project files to the project path to ensure that the Dependency Analyzer detects all project files.
Specify Project Details, Startup Folder, and Derived Files Folders
On the Project tab, in the Environment section, click Details. Use the Project Details dialog box to:
Edit the project name or add a description.
View the Project root folder. You can change your project root by moving your entire project on your file system, and reopening your project in its new location. All project file paths are stored as relative paths.
View or edit the Start Up 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.
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 Preferences. Select MATLAB > Project and specify the Default folder.
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.
To configure an existing file to run on project startup and shutdown, or to specify environment options, click the Startup Shutdown button in the Project tab. In the Manage Project Startup and Shutdown dialog box:
Add or remove startup and shutdown files. You can change the execution order using the arrow buttons.
Use the check boxes to specify environment options. Select Start Simulink before this project starts to start Simulink when you open the project. Select Refresh Simulink customizations to run
sl_customizationfiles on project startup and shutdown.
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 Shortcuts tab, this example project has shortcuts for the top-level model, a utility function to rebuild S-functions, and a design description document.
Click the shortcut
F14 Modelto open the root model for this project.
Click the shortcut
Rebuild Project's S-functionsto generate the S-function.
Click the New Shortcut button to create new shortcuts for a project file.
Right-click a shortcut and select Edit Shortcut to edit a shortcut.
Explore Files Views
In the Files view, select the Project (number of files) view to manage the files within your project. This view only shows files that are part of your project.
Use the All view to see all the files in your working copy. This view shows all the files that are under the project root, not just the files that are in the project. This view is useful for adding files to your project from your working copy.
In any Files view, at the top right, change the layout from Tree to List to view the files as a list. Click Organize View to customize the views and to sort files.
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.
Run Checks and 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 Project Checks, click Upgrade Project.
To upgrade all files, run all checks, and apply fixes automatically where possible, click Upgrade. If you want to change the settings, use these options before clicking Upgrade:
If you want to run upgrade checks but not apply fixes automatically where possible, clear the check box Apply upgrades automatically.
If you want to change which files to upgrade and which checks to run, click Change Options. In the Upgrade Options dialog box, clear check boxes for models and checks you want to exclude from the upgrade.
The Upgrade Project tool apply all fixes automatically when possible, upgrade all model hierarchies in the project at once, and produce a report.
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.
Share your project as an archive and send it by email. On the Project tab, select Share > Archive.
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.
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.
Perform Impact Analysis with a Project