Merge Simulink models from a reference report -MATLAB and Simlink (2023)

To combinesimultaneous callComparative report templates.

Merge tools allow you to:

  • Resolve conflicts in template files under source code control using three-way merge. open by selectingsee conflicts.

  • Merge any two template files using bidirectional merging. open by selectingcomparecontext menu items.

  • ConectarMATLAB®Function block code that uses text diff reports.

Resolve conflicts with three-way template merging

If there is a conflicting template file under source control in the current project or folder browser, right-click and selectsee conflicts. Conflicts can be resolved using the 3-Way Model Merge tool. Check your local file with the conflicting version and the main parent file and decide which changes to keep. You can resolve the conflict and submit the changes.

  1. For an example of a three-way connection, seeResolve conflicts with three-way Simulink.

  2. In the project, find the conflicting template file, right-click and selectsee conflicts. you can only seesee conflictsfrom the context menu if source control marks the file as conflicting.

    Merge Simulink models from a reference report-MATLAB and Simlink (1)

The Merge tool automatically resolves all possible differences and displays the results in a fileheglass. Review the auto-merge options, edit them if necessary, and decide how to resolve any remaining conflicts.

  1. Check the Combine report columns.

    • On top,EU,A base, EUMythe columns show the differences in the conflicting version, its version, and the parent ancestor of both files.

    • Below,hedisplays the local file where you will merge the changes. The Merge tool has already automatically merged the differences that you can merge.

    Merge Simulink models from a reference report-MATLAB and Simlink (2)

  2. Check the difference by clickingNextor by clicking on a line in the fileEU,A base, EUMycolumns.

    The Merge Tool displays two templates (or, if you have selected a configuration, you will see two Template Configuration Parameters dialog boxes). By default you seeEUEUhemodels to follow.

    Merge Simulink models from a reference report-MATLAB and Simlink (3)

  3. Select templates to display using toolbar buttonsTo combinePato:Modellubricantinferior model. View templates to help you decide what to merge.

    Merge Simulink models from a reference report-MATLAB and Simlink (4)

    To use

    If you open the merge tool withsee conflictsso modelsEU,A base, EUMyare temporary files that display conflicting versions. Check them out to decide how to connect. Hehethe model is a copyMycontaining the merge results in the report.

  4. Select the version you want to keep for each change by clicking the buttons belowheglass. You can merge modified, added, or deleted nodes and merge individual parameters. The Combine tool automatically selects one option for each difference it can resolve. Review your selections and change them if desired.

    Merge Simulink models from a reference report-MATLAB and Simlink (5)

    Look for warnings in the Conflicts column. Select the button you want to useEU,A base, lubricantMyfor each conflicting element.

    Merge Simulink models from a reference report-MATLAB and Simlink (6)


    Merge blocks before lines and merge states and intersections before merging transitions. Then the Merge tool tries to combine all the lines into blocks. To seecollage tips.

  5. Some differences need to be merged manually. Inhein the Conflicts panel, look for the manual merge icon in the Conflicts column, indicating that you need to take action.

    Merge Simulink models from a reference report-MATLAB and Simlink (7)

    Make manual changes in the Editor. The Diff report cannot be updated to show changes made in the Editor, so try making changes manually after all the simplest connections have been added to the report.

    After resolving the conflict using the File Editorheselect a verification option to mark the node as complete.

    Merge Simulink models from a reference report-MATLAB and Simlink (8)

  6. Check the summary table to see the number of automatic connections and the remaining conflicts you need to resolve.

    Merge Simulink models from a reference report-MATLAB and Simlink (9)

    Verify that the changes have filtered out of the current view by reviewing the summary table tab titles. The titles of the Filtered View and All Changes tabs show the number of changes. By default, the report hides all non-functional changes. Turn off active filters to see all identified changes.

  7. If you are satisfied with the selected merge options and any manual merges in the fileheclick on the fileaccept and close. This action saves the destination file with all the merged files and means that the conflicting file is resolved in the source control tool.

    To save and not mark the conflict as resolved, selectaccept and close>save and close.

For more information on how to resolve conflicts in the changelist of modified files in a project, seeresolve conflicts.

Use three-way merging with external source control tools

If you use source control outside of MATLAB, you can customize external source control tools to open a three-way join (or a two-way join for differences).

For instructions, seeCustomize external source control to use MATLAB for compare and join.

Open a three-way connection without using source control

If you don't use source control or want to select three files to merge, you can open the three-way merge using the functionslxmlcomp.slPołącz. Specify the files you want to merge, for example:

slxmlcomp.slMerge(base file, my file, your file, destination file);
A three-way merge opens where you can merge your changesof the file,my file, EUyour filecdestination file.

Fusion of bidirectional models

You can connect two Simulink®comparative report templates. HecompareContext menu items in the current project or folder browser open bidirectional model merging. If you are using source control and want to resolve conflicts with a three-way template join, seeResolve conflicts with three-way template merging.

The merge feature allows you to merge two versions of a project modeled in Simulink. You can combine individual parameters, blocks or entire subsystems. Entire subsystems can only be fully linked if they are fully inserted or fully deleted subsystems.

  1. OfComparisonmark, clickfusion mode. The Destination panel will appear at the bottom of the report.

  2. Use the same workflow as the three-way merge. Use the buttons to select the differences to keep in the destination file.


    Merge blocks before lines and merge states and intersections before merging transitions. To seecollage tips.

  3. Visualize the results in the report and in the templates. give a clicksave filecopies the temporary destination file to the correct file in the diff and restarts the diff.

  4. (Optional) To undo all merge operations, clickclose the connectionwithout saving the file.

  5. Check the join changes in the Simulink editor. If necessary, connect any lines that the software did not automatically connect. The Diff report is not updated and does not show changes made in the Editor.

collage tips

  • In the Simulink part of the report, link the models in the following order. In the destination file:

    1. Delete lines you don't want to keep.

    2. Remove blocks you don't want to keep.

    3. Add the blocks you want to keep.

    4. Add the lines you want to keep.

    5. Select the parameters you want to keep.

    You must merge states and intersections before merging transitions; otherwise, you cannot create joins in the report.

    For an example of how to merge a multi-node change, seeCompare and merge Simulink models with state flow.

  • Not all parameters can be combined. In this case, only a radio button is displayed on the target panel, indicating which version is in the target model.

  • For information on how to combine templates with identical names, seeCompare models with identical names.

To combineMATLABFunction block code

  1. To combine differences in MATLAB function block code, create a comparison report for the main models.

  2. give a clickfusion modebutton.

    This will create and open a third file called targetFile. May include left or right model changes.

  3. Use the buttons to the right of the report to select the changes you want to make to the destination file.

  4. Save these changes to the appropriate template usingsave filetoolbar button.

related topics

  • Compare Simulink models
  • See the differences in the original models.
  • Source control in projects.
  • resolve conflicts
  • compare versions
  • Customize external source control to use MATLAB for compare and join


You clicked on the MATLAB command link:


Run the command by entering it in the MATLAB command window. Web browsers do not support MATLAB commands.

Merge Simulink models from a reference report-MATLAB and Simlink (10)

select a website

Select a site to get translated content, if available, and to check out local events and offers. Depending on your location, we recommend choosing:.

You can also select a site from the list below:


  • Latin America(Spanish)
  • Ter(English)
  • USA(English)


  • Belgium(English)
  • Dania(English)
  • Germany(German)
  • spain(Spanish)
  • Finland(English)
  • France(French)
  • Ireland(English)
  • Italy(Italian)
  • Luxembourg(English)
  • Netherlands(English)
  • Norway(English)
  • Austria(German)
  • Portugal(English)
  • Sweden(English)
  • Swiss
    • German
    • English
    • French
  • United Kingdom(English)

Asia and Pacific

  • Australia(English)
  • Independent(English)
  • New Zealand(English)
  • Porcelain
  • Japan(Japanese language)
  • Korea(Korean)

Please contact your local office


Top Articles
Latest Posts
Article information

Author: Terrell Hackett

Last Updated: 07/29/2023

Views: 6031

Rating: 4.1 / 5 (72 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Terrell Hackett

Birthday: 1992-03-17

Address: Suite 453 459 Gibson Squares, East Adriane, AK 71925-5692

Phone: +21811810803470

Job: Chief Representative

Hobby: Board games, Rock climbing, Ghost hunting, Origami, Kabaddi, Mushroom hunting, Gaming

Introduction: My name is Terrell Hackett, I am a gleaming, brainy, courageous, helpful, healthy, cooperative, graceful person who loves writing and wants to share my knowledge and understanding with you.