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. You can use the report to analyze the comparison results similarly to how you would in the Simulation Data Inspector. You can change the layout of the report between the interactive view and a printable view.
This example shows how to create an 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 in the Simulation Data Inspector.
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.
Expand the Baseline drop-down and select
Run 1: slexAircraftExample.
Expand the Compare to drop-down and select
Run 2: slexAircraftExample.
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);
To save the comparison results, you can generate an interactive web report. 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. Select
Compare as the Type. In this example, all signals in the run comparison did not match, so a report containing only mismatched signals contains all the signals.
You can specify a title and author to include in the header for the report. By default, the title is created from the names of the compared runs. This example provides a different title that describes the variable values evaluated by the simulations and comparison.
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 prevent long block paths from 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.
The interactive 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 result you want to view in the plots. The Properties table shows all the metadata for the compared signals and highlights metadata that differs. You can scroll in the Properties table to see all the metadata. When the comparison contains more signals than fit in the results table, you can scroll in the results table as well.
You can adjust the size of the panes in the report by dragging the borders. For example, you could make the Properties pane larger, since the table of compared signals does not use all the space in the signals pane.
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.
Inspecting the plots in the report allows you to 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 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 (For example,
0.01) for the
Stick signal so the comparison results are within tolerance. To share the updated results, you can generate a new comparison report.
After finalizing the analysis and presentation of the comparison results, you can print a comprehensive view of the results using the interactive web report. To switch to the printable view, select the Printable radio button, or press Ctrl+P to see a print preview in the browser. In the printable view, the metadata and plots for all signals are stacked, with the summary table at the top.