Main Content

Dependency Analyzer

Visualize dependencies, find required files, and assess the impact of changes

Since R2023a

Description

The Dependency Analyzer app is an interactive tool for visualizing and analyzing dependencies among files.

Every design, whether it is a folder, a Simulink® model, or a project, requires a set of files and products to run successfully. Dependencies include data files, model references, linked libraries, MATLAB® and C/C++ code, Stateflow® charts, and requirements documents.

Use the Dependency Analyzer to perform a dependency analysis. You can run a dependency analysis at any point in your workflow. In a collaborative environment, you typically check dependencies:

  • When you set up or explore a design for the first time

  • When you run tests to validate changes to your code

  • Before you submit a version of your code to source control

  • Before you share your code

With the Dependency Analyzer, you can:

  • Find required products and add-ons.

  • Investigate and resolve problems.

  • Perform an impact analysis to determine the impact of changing particular files.

  • Export the dependency analysis results.

Dependency Analyzer app. Dependency graph in the center. toolstrip on the top, Legend pane on the left, and Properties panel on the right.

Open the Dependency Analyzer App

  • MATLAB toolstrip: On the Apps tab, under MATLAB, click the Dependency Analyzer icon .

    For instructions on how to run a dependency analysis on a folder or a file, see Dependency Analysis for Folders and Files.

  • Project toolstrip: On the Project tab, click the down arrow to expand the Tools gallery. Under Apps, click Dependency Analyzer.

    Perform a project dependency analysis to explore the dependency graph using source control and project-specific views. For more details, see Analyze Project Dependencies. For projects that contain models, Dependency Analyzer provides model-specific views. See Explore the Dependency Graph, Views, and Filters (Simulink).

  • Simulink Editor: On the Modeling tab, on the far right of the Design section, click the arrow. Under Dependencies, click Dependency Analyzer.

    Perform a dependency analysis to examine models, subsystems, and libraries referenced directly or indirectly by the model using model-specific views. For more details, see Analyze Model Dependencies (Simulink).

  • MATLAB Command Window: Enter dependencyAnalyzer.

Examples

expand all

  1. Open the Dependency Analyzer. In MATLAB, on the Apps tab, under MATLAB, click the Dependency Analyzer icon .

    Open Files on the left. Open Folder button on the right.

  2. Select the files or folder you want to analyze.

    • To analyze dependencies between all files in a folder, click Open Folder and select the folder you want to analyze. If the folder you selected is not on the search path, MATLAB changes the current folder to the selected folder.

    • To analyze the dependencies of a set of files in a folder, click Open Files and select the files you want to analyze.

  3. The dependency graph shows:

    • How 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.

    • Required products in the Properties panel under Products. Point to a product, such as MATLAB, and click the magnifying glass icon . The graph highlights the files that use this product.

    • Warnings in the Properties panel under Problems. Common problems include missing files, files with syntax errors, files with unsaved changes, and out-of-date derived files. Point to a problem, such as Unsaved changes, and click the magnifying glass icon . The graph highlights the files with this problem.

    Dependency Analyzer default view. Dependency graph in the center, toolstrip on the top, Legend pane on the left, and Properties panel on the right.

  4. Explore the different views in the Views section of the Dependency Analyzer toolstrip to investigate your files dependencies.

    • The MATLAB Files view shows only MATLAB files (such as .m, .mlx, .p, .mlapp, .fig, .mat, and .mex) in the view and colors them by type.

    • The Class Hierarchy view shows the class inheritance graph and colors the files by type (class, enumeration class, or abstract class). If the class is not on the search path, the Dependency Analyzer cannot determine the class type.

    If the folder you are analyzing is a project, for instructions on how to use project-specific views, see Analyze Project Dependencies.

    Tip

    To package, share, or put your design under source control, create a project from your folder. For more details, see Create a New Project from a Folder (Simulink). Perform a project dependency analysis to explore the dependency graph using source control and project-specific views.

    If the file you are analyzing is a Simulink model, for instructions on how to use model-specific views, see Analyze Model Dependencies (Simulink).

    Tip

    To package, share, or put your design under source control, create a project from your model. For more details, see Create a Project from a Model (Simulink). Perform a project dependency analysis to explore the dependency graph using source control and project-specific views.

  5. Use the graph to investigate problem files graphically.

    1. In the Properties pane, in the Problems section, point to a problem, such as Unsaved changes, and click the magnifying glass icon . The graph highlights the files with this problem.

      To examine these files, use the arrows in the search box (for example, Problem: Unsaved changes).

      To undo the highlighting, close the search box.

    2. To see more information about a problem file, select the file in the graph. In the Properties pane, in the Problems section, you can see details including the path, type, and problems for this file.

      For example, if a file has unsaved changes, save the file in the MATLAB editor. For more details on how to fix problems, see Resolve Problems.

    3. To update the graph and the Problems list, click Analyze.

  6. Export all the files displayed in the dependency graph.

    1. Click the graph background to clear the selection on all files.

    2. In the Export section, click Export. Select from these options:

      • Save to Workspace — Save the file paths to a variable in the workspace.

      • Generate Dependency Report — Save the dependency analysis results in a printable report (HTML, Word, or PDF).

      • Package As Archive — Export the files in the graph as an archive.

      • Save As GraphML — Save the dependency analysis results as a GraphML file.

      • Save As Image — Save the displayed dependency graph as an image.

    You can also export a subset of files in the graph. Select the files, then click Export. The menu displays how many files are selected. The Dependency Analyzer exports only the selected files.

    Number of selected files on top of the Export menu.

    Note

    To ensure the archive you share does not have missing files, when you use Package As Archive, the Dependency Analyzer includes the selected files and all their dependencies in the archive.

Related Examples

Tips

  • Use the clickable arrows to investigate further dependencies between files.

    Selected arrow in the graph with corresponding dependency details in the panel on the right.

  • Use the check boxes in the Legend pane to filter out a group of files.

  • Use the Add to selection button in the Legend panel to select all files in the graph with the specified legend.

    Add to selection button next to every entry in the Legend panel on the left.

  • Create a project from the dependency graph. Projects enable you to package, share, or put your design under source control.

    To create a project from all the files displayed in the dependency graph, click the graph background. This action clears all selected files.

    1. In the Dependency Analyzer toolstrip, in the Export section, click Create Project.

    2. In the Create Project window, click OK.

      The Dependency Analyzer creates a project and reloads the graph.

    You can also create a project from a subset of files in the graph. Select the files, then click Create Project. The Dependency Analyzer includes the selected files and all their dependencies in the project.

Version History

Introduced in R2023a

expand all