Main Content

Using a Project with SVN

This example shows how to use a project to manage the files within your design. Starting with an existing project that is already checked into source control, this example shows how to view modified files, compare file revisions, and analyze project dependencies.

Download and open the example project using the MATLAB® command provided by the Copy Command button.

The MATLAB desktop shows the Project panel and Source Control 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. For instructions on how to check out files from an SVN repository, see Work with Files Under SVN in MATLAB.

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.

The source control column provides source control information on individual files such as Unmodified, Added, Modified, or Deleted.

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.

View Source Control Information

When your project is under source control, for easier interaction, combine the Project and Source Control panels by dragging one panel on top of the other. If the Source Control icon Source Control panel icon is not in the sidebar, click the Open more panels button Open more panels icon and select the Source Control panel.

To view source control information such as the remote URL, right-click the white space in the Project panel and select Source Control > View Details. Alternatively, in the Source Control panel, click the View Details button View Details icon.

View Modified Files and Local Changes

Open and make a change to one of the models in the models folder or to one of the MATLAB files in the utility folder. For example, add a comment in find_top_models.m in the utility folder.

To review, analyze, and commit modified or added project files, use the Source Control panel.

  • The Modified Files section lists the file you made changes to, for example, find_top_models.m.

  • The Modified Files section also includes changes the resources folder. These are internal project definition files generated by your changes. The project definition files allow you to add metadata to files, for example, by creating shortcuts, adding labels, and adding a project description. Project definition files also define the files that are added to your project. You can review changes in revisions of project definition files like any other project files.

  • To review changes in a modified file, right-click the file, for example, find_top_models.m and select View Changes. The Comparison Tool summarizes the change in an interactive report. To save a printable version of the report, select Publish > HTML, Word, or PDF.

  • To commit your changes, click Commit.

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.

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 currently 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.

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.

See Also

Topics