Create an Interactive Comparison Report

When you compare data using the Simulation Data Inspector, you can create an interactive web-based comparison report to share or archive the results. The report is a self-contained HTML file, and viewing the report only requires a web browser. Using the report, you can analyze the comparison results similarly to how you would in the Simulation Data Inspector.

This example shows how to create the interactive comparison report using data loaded from a session file. For more information about importing data into the Simulation Data Inspector or logging data from a simulation, see View Data with the Simulation Data Inspector.

Load and Compare Data

This example uses data created by simulating the slexAircraftExample model that was saved in the session file dataToCompare.mldatx. Both simulations used the square wave input from the Pilot block in the model. The first simulation uses the input filter design saved in the model with a time constant of 0.1. The time constant was changed to 1 for the second simulation.

Open the Simulation Data Inspector and the session file to load the data into the Simulation Data Inspector for comparison.


In the Simulation Data Inspector, navigate to the Compare tab and compare the two runs.

  1. Expand the Baseline drop-down and select Run 1: slexAircraftExample.

  2. Expand the Compare to drop-down and select Run 2: slexAircraftExample.

  3. Click Compare.

Alternatively, you can use the Simulink.sdi.compareRuns function to perform the comparison.

runIDs = Simulink.sdi.getAllRunIDs;
runID1 = runIDs(end-1);
runID2 = runIDs(end);

diffRes = Simulink.sdi.compareRuns(runID1,runID2);

Generate the Interactive Comparison Report

To save the comparison results, you can generate an interactive web report that contains the comparison results. To create the report, click the Report button.

In the Create Report dialog, you can specify the type of report you want to create and the data you want to include in the report. Specify the Type as Compare and the Style as Interactive web view. In this example, all signals in the run comparison did not match, so a report containing only mismatched signals also contains all the signals.

Enter a descriptive file name for the report file. You can also specify where to save the report. By default, the Simulation Data Inspector saves the report in a folder called sdireports in the working directory.

You can also enable the option to add an incrementing number to the end of the specified file name to avoid overwriting existing report files. For models that log signals throughout the model hierarchy, consider enabling the Display partial block path option to avoid very long block paths appearing in the report. In this example, the signals are all logged in the top-level of the model hierarchy.

After specifying the options for the report you want to create, click Create Report. The generated report automatically opens in the system browser.

Inspect Comparison Results in the Interactive Web Report

The report information and layout is similar to what you see on the Compare pane of the Simulation Data Inspector. In the Comparisons table on the left, you can select the signal results to view on the plots. The Properties table shows all the metadata for the compared signals and highlights metadata that differs. You can scroll in Properties table to see all the metadata, and when the comparison contains more signals than fit in the Comparisons table, you can scroll through the results there as well.

The information in the table indicates that the comparison results for the Stick signal are out of tolerance with a maximum difference of 0.78. In the model, the Stick signal is the output from a Signal Generator block, and the filter time constant should not affect the block output. Select the Stick signal to investigate the comparison results.

By inspecting the plots in the report, you can see that the differences occur at the rising and falling edges of the square wave. The slexAircraftExample model uses a variable-step solver. The differences occur because the new time constant value changes the system dynamics, and the solver calculates slightly different time steps for the second simulation. The transition of the square wave is very sharp, so small timing differences can result in large magnitude differences.

Because the differences in the Stick signal are due to modeling rather than a real change in system dynamics, you could go back to the Simulation Data Inspector and specify a small time tolerance like 0.01 for the Stick signal so the comparison results are within tolerance. To share the updated results, you can generate a new interactive comparison report.

See Also

Related Topics