|On this page…|
Try an example Simulink® project to see how the tools can help you organize your work. Projects can help you manage:
Your design (model and library files, .m, .mat, and other files, source code for S-functions, data)
A set of actions to use with your project (run setup code, open models, simulate, build, run shutdown code)
Working with files under source control (check out, compare revisions, tag or label, check in)
The Airframe example shows how to:
Set up and browse some example project files under source control.
Examine project shortcuts to run setup and shutdown tasks and 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 SVN source control.
The Simulink Project 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.
In the Project tree view, select the Files node to manage the files within your project. When Project Files View is selected, only the files in your project are shown.
To see all the files in your sandbox, click the Project Files View button and select All Files View. 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.
Click the x to clear the search.
To view files as a list instead of a tree, click the List view button.
To sort files and to customize the columns, click the Actions button at the far right of the search box.
You can dock and undock the Simulink Project into the MATLAB® Desktop. If you want to maximize space for viewing your project files, undock the Simulink Project. Drag the title bar to undock it.
You can use shortcuts to automatically run startup or shutdown tasks, and to easily find files within a large project.
You can view and run shortcuts on the Project Shortcuts toolstrip. The shortcuts are organized into groups that you specify through the Shortcut Management view.
In this example, you can see that some files are set as Run at Startup shortcuts. Startup shortcut files automatically run, load, or open when you open the project. You can use these shortcuts to set up the environment for your project. The file set_up_project.m sets the MATLAB path, and defines where to create the slprj folder.
Open the Set Up Project shortcut to understand how it works. In the Shortcut Management view, double-click the shortcut, or right-click and select Open. The file set_up_project.m opens in the Editor. The following lines use the project API to get the current project and the root folder:
project = simulinkproject; projectRoot = project.RootFolder;
The shortcut Clean Up Project is set as a Run at Shutdown shortcut. This type of shortcut runs before the current project closes. In this example, clean_up_project.m resets the environment changes made by set_up_project.m.
For details on configuring shortcuts to set your project path, see Set Project Path at Startup and Reset at Shutdown.
In the Project tree view, select the Files node and select Project Files View.
Right-click a file, and select Create Shortcut.
In the Shortcut Management view, right-click the shortcut you created and select Set Shortcut Action > Startup to make the file run, load, or open at startup.
When you open the project, the project performs the default action for startup shortcut files depending on their type:
Run .m files.
Load .mat files.
Open Simulink models.
For details on shortcuts, see Automate Startup Tasks with Shortcuts.
You can use shortcuts to make scripts easier to find in a large project. 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.
The shortcut file builds a MEX-file. If you do not have a compiler set up, follow the instructions to choose a compiler.
Select the Project Shortcuts tab in the toolstrip, and click the shortcut Rebuild Project's S-functions.
Open the rebuild_s_functions.m file to explore how it works.
Open the top model.
On the Project Shortcuts tab, click the shortcut F14 Model to open the root model for this project. This model runs only after you compile the required S-function.
To create new shortcuts to access frequently used files, select the Project > Files node, right-click a file, and select Create Shortcut > General or any other shortcutGroupName. This action creates a basic shortcut with no startup or shutdown action.
Open and make changes to files and review changes.
In Project Files View, expand the utilities folder.
Either double-click to open the set_up_project file for editing from the Simulink Project, or right-click and select Open.
Make a change in the Editor, such as adding a comment, and save the file.
Under Files, select the Modified Files node. The files you changed appear in the list.
To review changes, right-click the set_up_project file in the Modified Files view and select 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 to Ancestor, and you have Simulink Report Generator™ installed, this command runs a Simulink XML comparison.
If you have Simulink Report Generator, try the following example.
Select the Files node and expand the models folder.
Either double-click to open the AnalogControl file for editing from the Simulink 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, right-click the file in the Modified Files view and select Compare to Ancestor.
The Comparison Tool opens a report.
In the Modified Files view, under Precommit actions, click Check Project 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 Fix 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.
Run a file dependency analysis on the modified files in your project to check that all the required files were added to the project.
In the Modified Files view, under Precommit actions, click Dependency Analysis to analyze the modified files.
The Simulink Project displays the Dependency Analysis node and selects the modified files for analysis, for example, set_up_project.m.
Include all files in the analysis, to analyze the whole project, not just the modified files. To quickly include all files, click the list of files, and press Ctrl+A to select all the files. Then right-click and select Include.
On the Dependency Analysis tab, click Analyze.
Review reported problem files. Observe that Problem files automatically appears in the search box for filtering file views.
Observe that the S-function binary file, timesthree.mexw64, is required by the project but is not currently part of it. Expand the Problem Description column to read the message: Not in project.
Click the problem file to view where it is used. Under Upstream Dependencies, the Name and Path columns display the name and location of the file that uses the selected problem file.
You might want to 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.
Right-click the problem file and select Add External File. You remove the file from the problem files list, and the next time you run dependency analysis, this file does not appear as a problem file. This action does not add the external file to the project. In this example, you do not want to add the binary file to the project, but instead use the script to regenerate it from the source code in the project. Use Add External File to stop such files being marked as problems.
Select the Impact node to view the dependency graph of the project structure.
On the Impact tab, choose Select > Modified Files.
To view dependencies of the modified files, use the Find button on the toolstrip. For example, select Find > All Dependencies of Selection.
The graph shows only the modified files and their file dependencies.
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 Modified Files view, under Precommit actions, click Check Project to make sure that your changes are ready to commit.
Observe the Modified Files list includes a .SimulinkProject folder. The files stored in the .SimulinkProject folder are internal project definition files generated by your changes. These definition files allow you to add a label to a file without checking it out. You do not need to view the definition files directly unless you need to merge them, but they are listed so you know about all the files being committed to the source control system. See Project Definition Files.
To commit your changes to source control, click Commit Modified Files.
Enter a comment for your submission, and click Submit.
Watch the messages as the example source control commits your changes.
Click the root tree node Project: Simulink Project Airframe Example to see information about:
The open project, which includes a description and the location of the project root folder.
The source control tool used by the current project.
This Airframe example project is under the control of the SVN source control tool.
For next steps, see Project Management .