Try an example project to see how the tools can help you organize your work. Projects can help you manage:
Your design (model and library files,
.mat, and other files, source code for S-functions, and
A set of actions to use with your project (run setup code, open models, simulate, build, and run shutdown code)
Working with files under source control (check out, compare revisions, tag or label, and check in)
The Airframe example shows how to:
Set up and browse some example project files under source control.
Examine project shortcuts to access frequently used files and tasks.
Analyze dependencies in the example project and locate required files that are not yet in the project.
Modify some project files, find and review modified files, compare to an ancestor version, and commit modified files to source control.
Explore views of project files only, modified files, and all files under the project root folder.
Run this command to create a working copy of the project files and open the project:
The project example copies files to your temporary folder so that you can edit them and put them under Git™ source control.
The Project window opens and loads the project. The project is configured to run some startup tasks, including changing the current working folder to the project root folder.
Alternatively, you can try this example project using SVN source control, by
sldemo_slproject_airframe_svn. The following example shows
the options when using Git.
In a Project, examine the Files view to manage the files within
your project. When the Project (
files) view is selected, only the files in your project are
To see all the files in your sandbox, click All. 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 the project from your sandbox.
To find particular files or file types, in any file view, type in the search box or click the Filter button. You can also search inside files.
Click the x to clear the search.
To view files as a list instead of a tree, use the Layout control.
To sort files and to customize the columns, click the Organize view button at the far right of the search box.
You can dock and undock the Project into the MATLAB® Desktop. If you want to maximize space for viewing your project files, undock the Project. Drag the title bar to undock it.
You can use shortcuts to make scripts easier to find in a large project. View and run shortcuts on the Project Shortcuts toolstrip. You can organize the shortcuts into groups.
In this example, the script that regenerates S-functions is set as a shortcut so that a
new user of the project can easily find it. You can also make the top-level model, or
models, within a project easier to find. In this example, the top-level model,
slproject_f14.mdl, is a shortcut.
Regenerate the S-functions.
On the Project Shortcuts tab in the toolstrip, click the shortcut Rebuild Project's S-functions.
The shortcut file builds a MEX-file. If you do not have a compiler set up, follow the instructions to choose a compiler.
rebuild_s_functions.m file to explore how it
Open the top model.
On the Project Shortcuts tab, click the shortcut F14 Model to open the root model for this project.
To create shortcuts to access frequently used files, select the Files view, right-click a file, and select Create Shortcut.
You can also specify files to run at startup and shutdown. See Automate Startup Tasks.
Open and make changes to files and review changes.
Select the Files view. View folders using the tree layout, and then expand the
Either double-click to open the
find_top_models file for
editing from the project, or right-click and select
Make a change in the Editor, such as adding a comment, and save the file.
In the project Files view, select the tab Modified (
of files). After editing the file, you see
Modified (2). The files you changed appear in the list. You
edited a file in the utilities folder. Observe that the Modified files list also
resources folder. The files stored in the
resources folder 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.
See Project Definition Files.
To review changes, right-click the
find_top_models file in the
Modified files view and select Compare > Compare to Ancestor.
The MATLAB Comparison Tool opens a report comparing the modified version of the file in your sandbox against its ancestor stored in the version control tool. The comparison report type can differ depending on the file you select. If you select a Simulink® model to Compare > Compare to Ancestor, this command runs a Simulink model comparison.
To compare models, try the following example.
In the Files view, select the Project (
files) tab, and expand the
Either double-click to open the
AnalogControl file for editing
from the project, or right-click and select Open.
Make a change in the model, such as opening a block and changing some parameters, and then save the model.
To review changes, select the Modified (
files) tab. Right-click the modified model file and
select Compare > Compare to Ancestor.
The Comparison Tool opens a report.
To check that all required files are in the project, run a file dependency analysis on the modified files in your project.
In the Views pane, select Dependency Analysis.
The Impact graph displays the structure of all analyzed dependencies in the project. The right pane lists required toolboxes and any problem files.
To view the files that use a problem file, hover over the messages under Problems and click Find All.
The graph updates to display only the problem file, and the problem message in the right panel. The file is not in the project. To view the dependencies of the problem file, on the Dependency Analysis tab, in the Impact Analysis section, select Find > All Dependencies of Selection.
timesthree.mex64 is an S-function binary file
f14_airframe.slx. You can add binary files to your
project or, as in this project, provide a utility script that regenerates them from the
source code that is part of the project.
To remove the file from the problem files list, right-click the file and select Add External File. The next time you run a dependency analysis, the file does not appear as a problem file.
In this example, you do not want to add the binary file to the project, but instead use the script to regenerate the binary file from the source code in the project. Use Add External File to stop such files being marked as problems.
On the Dependency Analysis tab, in the Impact Analysis section, select Find > All Files.
In the Impact Analysis section, choose Select > Modified Files.
To view dependencies of the modified files, in the Impact Analysis section, select Find > All Dependencies of Selection.
To make sure that your changes are ready to commit, check your project. On the Project tab in the toolstrip, click Run Checks to run the project integrity checks. The checks look for missing files, files to add to source control or retrieve from source control, and other issues. The checks dialog box can offer automatic fixes to problems found. When you click a Details button in the Checks dialog box, you can view recommended actions and decide whether to make the changes.
For an example using the project checks to fix issues, see Upgrade Model Files to SLX and Preserve Revision History.
After you modify files and you are satisfied with the results of the checks, you can commit your changes to the source control repository.
In the Files view, select the Modified (
files) tab. The files you changed appear in the
To commit your changes to source control, on the Project tab, in the Source Control section, click Commit.
Enter a comment for your submission, and click Submit.
Watch the messages in the status bar as the source control commits your changes. Git commits to your local repository. To commit to the remote repository, use Push in the Source Control section. See Pull, Push, and Fetch Files with Git
To view and edit project details, on the Project tab, in the
Environment section, click Details. View
and edit details such as the name, description, project root, startup folder, and
generated files folders such as the
To view details about the source control integration and repository location, on the Project tab, in the Source Control section, click Git Details. This Airframe example project uses Git source control.
Alternatively, use the project API to get the current project:
project = currentProject;
For next steps, see Project Management.