Main Content

Understand Simulink Model Comparison Changes

Go through the comparison report to explore the differences in your Simulink® model files. If you have not yet run a comparison analysis, see Select Models to Compare.

The comparison report displays only differences in models. To step through the differences, use the Next and Previous buttons in the Navigate section of Comparison toolstrip. Alternatively, use the up and down arrows on your keyboard to navigate the report.

  1. The Comparison Tool shows the first change when the report opens. The selected item appears in a box. If the selected item has a match, the box appears in both the left and right trees.

    In this example report, the tool expands the Constant node and selects the modified Value, colored in purple.

    Model comparison report toolstrip on the top, the first model on the left, the second model on the right, and the color legend in the left bottom corner.

    By default, selecting an item in the model comparison report opens the original model and highlights the corresponding change item in the editor. If you select a Configuration Parameter item, the tool also opens the corresponding pane in the Configuration Parameters dialog box. For more information, see Open and Highlight Changes in Simulink Editor.

  2. To investigate the next change in the report, click Next.

    In this example report, the tool expands the MATLAB Function node and selects the added description, colored in blue.

  3. Investigate the next change. If additional comparisons are available for particular nodes, you see a Compare button to open a comparison report for the selected change.

    In this example report, you can compare the MATLAB Function block scripts in a new report. For more information about how to open sub-comparison reports, see Open Child Comparison Reports for Selected Nodes.

    Compare button in the bottom right of the MATLAB function tree comparison

  4. After stepping through all changes, the tool disables the Next button.

    If you click an item in the report, the Next and Previous buttons step through changes from the point you selected.

Tip

Use one of these methods to simplify the report and focus on critical changes.

  • For complex changes, use the model highlight capabilities to show and highlight model changes in the Simulink Editor. Highlighting changes helps you identify important differences quickly and simplifies the interpretation process. For more information, see Open and Highlight Changes in Simulink Editor.

  • For large model comparison reports, use filtering to reduce the report size and focus on critical changes in the report. By default, the report hides all nonfunctional changes. For information on how to create custom filters and apply built-in filters, see Simplify Comparison Report Using Filters.

Open Child Comparison Reports for Selected Nodes

When additional comparisons are available for particular items in the report, the Comparison Tool displays a Compare button to run a new comparison analysis for the selected node. Additional comparisons include comparison for variables in the Model Workspace, for modified long strings or scripts, for changes in MATLAB Function blocks, truth tables, and action tables.

In this example report, the tool detects changes in the MATLAB Function block and offers additional comparison. To compare the MATLAB Function blocks in a new report, click the Compare button displayed at the end of the MATLAB Function block node.

Compare button in the bottom right of the MATLAB function tree comparison.

Open and Highlight Changes in Simulink Editor

To quickly identify changes in your Simulink models, enable highlighting in the Comparison Tool. In the Comparison toolstrip, to always highlight changes in the Simulink Editor, enable Always Highlight.

When you select an item in the report, the Comparison Tool opens the models in the editor and highlights changes in yellow. If you select a configuration parameter item, the tool also displays the corresponding pane in the Configuration Parameters dialog box.

The two compared models to the right of the comparison report, the model in the left side of the report on top and the model in the right side of the report below. In the Comparison report the Constant node is selected. In the Simulink Editors, the corresponding block is highlighted in yellow.

Alternatively, you can highlight changes only when needed. In the Comparison toolstrip, clear Always Highlight and click Highlight Now to highlight the selection in the Simulink Editor.

By default, the Comparison Tool opens the two models you compare to the right of the comparison report, with the model in the left side of the report on top and the model in the right side of the report below. If you move or resize the models, the tool remembers your window positions for subsequent model highlighting operations.

To remember Simulink, Stateflow®, and truth table window positions across MATLAB® sessions, enter this command.

slxmlcomp.storeWindowPositions

To restore window positions to the defaults, enter:

slxmlcomp.clearWindowPositions

Simplify Comparison Report Using Filters

To simplify the comparison report and focus on critical changes, use filters. You can filter based on specific block types, specific changes, or other criteria, such as nonfunctional changes.

The comparison tool offers built-in filters for nonfunctional changes, block defaults, and signal lines changes. By default, the report hides all nonfunctional and block defaults changes. For more information on built-in filters, see Comparison Tool.

You can also create and export custom filters to share with others.

Filters gallery with built-in filters on top and custom filters below. Two buttons to Import and Export filters.

In this example, suppose you want to only inspect changes to Constant blocks.

  1. In the Comparison toolstrip, click New Filter.

  2. In the Name field box, enter Constant Block.

  3. In the Rules section, populate the table with these values.

    In the Select column, select Block. In the Parameter Name column, select BlockType. In the Parameter Value column, select Constant. Then, click OK.

    Note

    When you click the down arrows next to Parameter Name and Parameter Value, the Comparison Tool proposes options from the items available in the report.

    The tool stores custom filters in your MATLAB Preferences.

    For examples on how to create custom filters to filter out annotation changes, Inport and Outport block changes, or sample time parameter changes, see Comparison Tool.

  4. To see only changes to Constant blocks, in the toolstrip, in the Filter section, click Show, and then select the Constant Block filter.

To show all changes in the report, use one of these methods:

  • Hide nothing – Click Hide and disable all filters in the gallery.

  • Show everything – Create a custom filter named everything. In the New Filter dialog box, delete the contents of the first column so it shows Any. Then, remove the rest of the row under Parameter Name. Click Show and enable the everything filter.

You can export your custom filters to share with others.

  1. Expand the Filters gallery and click Export.

  2. In the Export Filters dialog box, select the filters you want to export and click OK.

  3. Specify a name and click Save.

  4. Share the exported filters file.

    Another user can import the filters by expanding the Filters gallery and clicking Import.

See Also

|

Related Examples

More About