Documentation Center

  • Trial Software
  • Product Updates

Using a Simulink® Project

This example shows how to use a Simulink 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 find and manage the files within your project. A common workflow illustrated by this example is fulfilling a change request for your design.

Setting Up the Example Files and Opening the Simulink Project Tool

1. Run the following commands to create and open a working copy of the project files.

Simulink.ModelManagement.Project.projectDemo('airframe');
rebuild_s_functions;
Loading Simulink...
Creating sandbox for project.
Adding files to source control.
Created temporary Simulink Project example files in "/tmp/R2014ad_357_3462/20140117T184515/airframe"
Running: /tmp/R2014ad_357_3462/20140117T184515/airframe/utilities/set_up_project.m
Loading: /tmp/R2014ad_357_3462/20140117T184515/airframe/data/buses.mat
Loading: /tmp/R2014ad_357_3462/20140117T184515/airframe/data/f14_digital_data.mat
Building with 'gcc'.
MEX completed successfully.

The project example copies files to your temporary folder so that you can edit them and use them under local version control.

The Simulink Project Tool opens and loads the project already under version control.

The project is configured to run some startup tasks.

Viewing Project Shortcuts

2. Click the Shortcuts node to view the startup tasks and other shortcuts. Simulink Project shortcuts can also be accessed from the Project Shortcuts toolstrip tab.

3. Click the List button at the top right of the Project user interface to view the shortcuts as a list of files.

You can use shortcuts to run startup or shutdown tasks, and to easily find files within a large project.

In this example you can examine shortcuts for the following tasks:

  • Some files are set as "Run at Start Up" shortcuts. Startup shortcut files are automatically run (.m files), loaded (.mat files) and opened (Simulink models) when you open the project. You can use these shortcuts to set up the environment for your project. In this example, the file set_up_project.m sets the MATLAB® path, and defines where the slprj folder is created. Open the file to view how it works. The following lines use the Simulink Project API to get the current project:

project = simulinkproject;
projectRoot = project.RootFolder;
  • "Run at Shutdown" shortcuts run before the current project closes. In this example, the file clean_up_project.m resets the environment changes made by set_up_project.m.

  • You can use shortcuts to make scripts easier to find in a large project. The script that regenerates S-Functions is a shortcut so that a new user of the project can easily find it.

  • You can use shortcuts to make the top-level model, or models, within a project easier to find. In this example, the top-level model slproject_f14 is a shortcut.

Viewing Source Control Information

Click the Source Control node to see information about the source control tool being used by the current project. This 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 file management views.

Using Shortcuts

4. Click the shortcut "F14 Model" on the Project Shortcuts toolstrip tab to open the root model for this project.

5. Click the shortcut "Rebuild Project's S-functions" on the Project Shortcuts toolstrip tab to generate the S-Function.

To create new shortcuts, select the Project Files view, right-click a file and select a shortcut group from the "Create Shortcut" menu. Go to the Shortcuts view to set an existing shortcut to "Run at Startup" or "Run at Shutdown".

Using Dependency Analysis

Run a file dependency analysis on the files within your project to check that all the files that are required by the project are stored with in it.

6. Click the Dependency Analysis node.

7. Click the Analyze button.

8. Review files reported in the Dependencies node. If problems are detected then all other results are filtered out. To see all the results of the file dependency analysis, click on the warning icon in the toolbar to turn off the "show only problem files" filter.

You can see from the results of the file dependency analysis that the S-Function binary, timesthree, is required by the project but is not currently part of it.

9. Click on timesthree in the Dependencies table to view where it is used within this project. In this example, it is used by f14_airframe.slx.

You may 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.

10. Right-click timesthree and select "Add External File". The next time you run dependency analysis, this file will not be marked as a problem file.

Modifying Files

You can open files for editing from the Simulink Project by double-clicking, or by right-clicking and selecting "Open".

11. Try opening and making changes to one of the utility MATLAB files, or one of the Simulink models.

Using The Modified Files View

12. Click the Modified Files node to see the files that you have modified in your sandbox.

You can use the comparison tool from the project to understand the changes you have made, perhaps as part of a peer-review process.

13. Right-click a file in the Modified File view and select "Compare to Ancestor".

This launches an appropriate comparison using the MATLAB Comparison Tool, comparing the modified version of the file in your sandbox against its ancestor stored in your version control tool. If you select a Simulink model, and you have Simulink® Report Generator™ installed, this runs a Simulink XML Comparison.

14. Click the "Commit Modified Files" button to commit your changes to Source Control.

The files stored in the .SimulinkProject folder are internal metadata files generated by your changes. The metadata allows you to add a label to a file without checking it out. You should never need to view metadata files directly. You should not need to review these files, but they are shown so that you know about all the files being committed to the source control system.

Viewing Project Information

Click the project 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. You can use the check box to set the current working folder to the project root when you open the project. Alternatively, you can use a project shortcut that uses the Simulink Project API to configure the current working folder when the project is first opened. For example, a project startup shortcut might set the "work" folder as the current working folder when the project is first opened.

Viewing Source Control Information

Click the Source Control node to see information about the source control tool being used by the current project. This 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 file management views.

Using Project File Views

Use the Project Files view to manage the files within your project. Only the files that are in your project are shown.

Use the All Files view to see all the files in your sandbox. This 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 that exist within your sandbox, but which are not yet part of the project.

In any file view, click the List button at the top right to view the files as a list.

Click the "cog" icon Actions button at the top right to customize the views and to sort files.

Right click the heading row of a file view to group files.

Further Information

Simulink Project documentationSimulink Project documentation

Was this topic helpful?