This example shows how to use an existing project to manage the files within your design. It shows how to 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 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.
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.
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.
1. To add or remove folders to the project path, on the Project tab, in the Environment section, click Project Path:
To add a folder (without subfolders) 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.
It is important to add project files to the project path to ensure the Dependency Analyzer detects all project files.
2. 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 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.
You can set project files, such as MATLAB scripts and Simulink® models, to run, open, or close when the project opens or closes.
3. 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. If execution order is important, change the 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_customization files on project startup and shutdown.
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.
4. 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 Model to open the root model for this project.
Click the shortcut Rebuild Project's S-functions to 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.
6. 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.
7. Use the All view to see all the files in your working copy. This 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.
8. In any Files view, at the top right, change the layout from Tree to List to view the files as a list. Click the Organize View button to customize the views and to sort files.
9. 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 .
10. 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. The next time you run the dependency analysis, the analyzer will not mark this file as a problem.
11. 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
timesthree.mexw64 and select Find Impacted.
12. Upgrade all models, libraries, and MATLAB code files in your project to the latest release using a simple workflow. 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, it is helpful to find required files and products using the Dependency Analyzer.
13. 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. On the Project tab, select Share > Archive. You can 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®. This adds Git source control to the open project.