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 toolboxes 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
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.
Run a dependency analysis on all the files in your project.
1. On the Project tab, 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 toolboxes 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
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 Not in project and click the magnifying glass icon .
The graph highlights the files with this specific problem, in this example,
Take actions to resolve the problem file.
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.
5. Open and make a change to one of the models, for example,
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.
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,
b. In the Impact Analysis section, click Impacted.
The dependency graph filters files and shows only those impacted by the changes you made to
8. Find where the dependency to
vertical_channel.slx is introduced in
a. Select the dependency arrow linking
b. In the Properties pane, click the link under Impacted. Simulink® opens the model
f14_airframe.slx and highlights the model block
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
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
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.
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,
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
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.