Main Content

Perform Impact Analysis with a Project

This example shows how to perform file-level impact analysis using the Dependency Analyzer. It shows how to visualize project structure, analyze project dependencies, find required add-ons and products, identify and fix problems, and assess how a change will affect other project files.

You can run a dependency analysis at any point in your workflow. In a collaborative environment, you typically check dependencies

  • when you first set up or explore a project

  • when you run tests to validate changes to your design

  • before you submit a version of your project to source control

  • before you share or package your project

Set Up the Example Files and Open the Project

Create and open a working copy of the project example files. MATLAB® copies the files to an example folder so that you can edit them. The example project is under Git™ source control.

Building with 'MinGW64 Compiler (C)'.
MEX completed successfully.

Visualize Project Structure and Dependencies

Run a dependency analysis on all the files in your project.

1. On the Project tab, click the down arrow to expand the Tools section. Under Apps, click Dependency Analyzer.

The dependency graph shows:

  • Your project structure and its file dependencies, including how files such as models, libraries, functions, data files, source files, and derived files relate to each other. Each item in the graph represents a file and each arrow represents a dependency

  • Relationships between source and derived files (such as .m and .p files, .slx and .slxp, and .c and .mex files), and between C/C++ source and header files

When no file is selected, the Properties pane shows:

  • The project details

  • The required products and add-ons for the entire project

  • The list of problems for the entire project, such as missing files, files not in the project, files with unsaved changes, and out-of-date derived files

Investigate and Resolve Problems

The Dependency Analyzer identifies problems, such as missing files, files not in the project, unsaved changes, and out-of-date derived files. You can examine problem files using the dependency graph or the file list.

Use the graph to investigate problem files.

2. In the Properties pane, in the Problems section, point to File not in project and click the magnifying glass icon .

The graph highlights the files with this specific problem, in this example, timesthree.mexw64.

Take actions to resolve the problem file.

3. Right-click timesthree.mexw64 and select Add to Project. To remove timesthree.mexw64 from the problem list without adding it to the project, right-click and select Hide Warnings.

4. Click Analyze to update the graph and the Problems list.

Tip: For large projects, use the File List to investigate your project problem files. For more details, see Investigate Problem Files in File List.

View Modified Files

5. Open and make a change to one of the models, for example, vertical_channel.slx.

a. In the dependency graph, double-click vertical_channel.slx to open it.

b. Move a block in vertical_channel.slx and save the model.

Use the Views gallery to display the source control status of each file in the dependency graph.

6. In the Dependency Analyzer toolstrip, expand the Views gallery and click Source Control.

The color of each item in the graph now represents its source control status. Since you made a change to vertical_channel.slx, its source control status is Modified.

Find the Impact of the Change

You can use the Impact Analysis tools to find:

  • the files impacted by a change to a file

  • the files required by a file to run successfully

7. Use the Impact Analysis tools to assess the impact your change has on other files.

a. In the dependency graph, select the file you modified, for example, vertical_channel.slx.

b. In the Impact Analysis section, click Impacted.

The dependency graph filters files and shows only those impacted by the changes you made to vertical_channel.slx.

8. Find where the dependency to vertical_channel.slx is introduced in f14_airframe.slx.

a. Select the dependency arrow linking f14_airframe.slx to vertical_channel.slx.

b. In the Properties pane, click the link under Impacted. Simulink® opens the model f14_airframe.slx and highlights the model block vertical_channel.

Identify Tests to Run

Project automatically associates Classification labels to each project files. This includes Design, Artifact, Convenience, Derived, and Test labels. The Test label identifies which files are tests. You can create additional classification to label your files. See Add Labels to Files.

9. Determine which tests you need to run to validate the changes you made to vertical_channel.slx.

a. To display the Classification labels associated to each file in the dependency graph, expand the Views gallery and click Classification.

The dependency graph showing only files impacted by the changes you made to vertical_channel.slx is now colored by label Classifications.

b. Identify the tests affected by your change.

In the graph, there are two Design files and one Test file impacted by the changes you made to vertical_channel.slx. f14_airframe_test.m is the test you need to run to validate the design changes.

Tip: To clear all filters and restore the graph to show all analyzed dependencies in the project, click Restore to Default. Alternatively, manually remove all filters showing at the top of the graph.

Export Results and Run Tests

You can send files to other Project tools using the Project menu. MATLAB exports only the selected files in the current filtered view.

10. Run the selected test to validate the design changes.

a. Select the test you want to run, in this example, f14_airframe_test.m.

b. In the Dependency Analyzer toolstrip, in the Export section, select Project > Send to Custom Task.

In the Custom Task dialog box, the test file f14_airframe_test.m exported from the impact analysis is already selected.

c. In the Custom Task dialog box, in the Custom task field, select Run Unit Tests and Click Run Task.

The Run Unit Tests custom task runs the MATLAB unit test you selected and creates a summary report. Examine the Results section after selecting the test you run, in this example f14_airframe_test.m.

  • To save the selected file paths to a variable, select Export > Save to Workspace.

  • To switch to the project Files view with the files selected, select Project > Show in Project.

See Also

Run a Dependency Analysis

Perform an Impact Analysis

Check Dependency Results and Resolve Problems