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 (number of files) view is selected, only the files in your project are shown.
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 (number 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 includes a
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 (number of
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 (number of 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.
On the Project tab, click on the down arrow to expand the Tools gallery. Under Apps, click Dependency Analyzer.
The dependency graph displays the structure of all analyzed dependencies in the project. The Properties pane lists required products, add-ons, and any problem files.
To highlight the problem files, in the Properties pane, in the Problems section, point to the message File not in Project and click the magnifying glass icon .
Select the dependency arrow to examine the dependency type.
timesthree.mexw64 is an S-function binary file required by
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 Hide Warnings. 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 Hide Warnings to stop such files being marked as problems.
View dependencies of the modified files.
In the Dependency Analyzer toolstrip, in the Views section, click Source Control. The color of each file in the graph now represents its source control status.
In the dependency graph, select the modified files. To select multiple files, press Shift and click the files.
In the Dependency Analyzer toolstrip, in the Impact Analysis section, click All Dependencies.
To make sure that your changes are ready to commit, check your project. To run the project integrity checks, on the Project tab, click the down arrow to expand the Tools gallery. Under Project Checks, click Check Project. 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.
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 (number of files) tab. The files you changed appear in the list.
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.