|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 local revision 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 local revision 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.
Click the Project Files view to manage the files within your project. Only the files in your project are shown.
Click the All Files view to see all the files in your sandbox. 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.
Click the Shortcuts node to view the startup tasks and other shortcuts.
The default List view displays the shortcuts as a list of files. These shortcuts are organized into shortcut groups. You can group shortcuts to organize them by type.
Select the Project Shortcuts tab in the toolstrip. Observe the shortcuts organised by group. You can run project shortcuts from any view in Simulink Project using the toolstrip.
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. Double-click the shortcut or right-click to 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:
p = simulinkproject; projectRoot = p.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.
Click the Project Shortcuts tab in the toolstrip. You can view and run shortcuts from any project view using the toolstrip. The shortcuts are organized into groups that you can specify in the Shortcuts view.
In the Project Files view, right-click a file, and select Create Shortcut.
In the Shortcuts 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 view, 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 the 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.
In the Simulink Project, click 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 Project Files view 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, 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 opens the Dependency Analysis view with the files you modified selected for analysis.
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.
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: Missing variable or file not on MATLAB path.
Click the problem file to view where it is used. The Used By column in the list at the bottom of the dialog box displays the file location 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.
Click the Impact node to view the dependency graph of the project structure.
Select Modified Files in the Analyze list.
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 Source Control node to see information about the source control tool used by the current project.
The Airframe example project is under the control of the Local Version Control tool.
For source control information on individual files (for example, modified, checked out), see the Modifications column in the Files views.
Click the root tree node Project: Simulink Project Airframe Example to see information about the currently open project, including a description and the location of the project root folder.
For next steps, see Project Management .