Simulink.sdi.report

Generate a Simulation Data Inspector report

Description

Simulink.sdi.report creates a Simulation Data Inspector report of the plotted data in the Inspect pane of the Simulation Data Inspector.

example

Simulink.sdi.report(Name,Value) uses additional options specified by one or more Name,Value pair arguments to generate a report of the specified view in the Simulation Data Inspector.

Examples

collapse all

This example shows how to create reports using the Simulation Data Inspector programmatic interface. You can create a report for plotted signals in the Inspect pane or for comparison data in the Compare pane. This example first generates data by simulating a model, then shows how to create an Inspect Signals report. To run the example exactly as shown, ensure that the Simulation Data Inspector repository starts empty with the Simulink.sdi.clear function.

Generate Data

This example generates data using model ex_sldemo_absbrake with two different desired slip ratios.

% Ensure Simulation Data Inspector is empty
Simulink.sdi.clear

% Open model
load_system('ex_sldemo_absbrake')

% Set slip ratio and simulate model
set_param('ex_sldemo_absbrake/Desired relative slip','Value','0.24')
sim('ex_sldemo_absbrake');

% Set new slip ratio and simulate model again
set_param('ex_sldemo_absbrake/Desired relative slip','Value','0.25')
sim('ex_sldemo_absbrake');

Plot Signals in the Inspect Pane

The Inspect Signals report includes all signals plotted in the graphical viewing area of the Inspect pane and all displayed metadata for the plotted signals.

% Get Simulink.sdi.Run objects
runIDs = Simulink.sdi.getAllRunIDs;
runID1 = runIDs(end-1);
runID2 = runIDs(end);

run1 = Simulink.sdi.getRun(runID1);
run2 = Simulink.sdi.getRun(runID2);

% Get Simulink.sdi.Signal objects for slp signal
run1_slp = run1.getSignalByIndex(4);
run2_slp = run2.getSignalByIndex(4);

% Plot slp signals
run1_slp.plotOnSubPlot(1, 1, true)
run2_slp.plotOnSubPlot(1, 1, true)

Create a Report of Signals Plotted in Inspect Pane

You can include more data in the report by adding more columns using the Simulation Data Inspector UI, or you can specify the information you want in the report programmatically with Name-Value pairs and the enumeration class Simulink.sdi.SignalMetaData. This example shows how to specify the data in the report programmatically.

% Specify report parameters
reportType = 'Inspect Signals';
reportName = 'Data_Report.html';


signalMetadata = [Simulink.sdi.SignalMetaData.Run, ...
    Simulink.sdi.SignalMetaData.Line, ... 
    Simulink.sdi.SignalMetaData.BlockName, ...
    Simulink.sdi.SignalMetaData.SignalName];

Simulink.sdi.report('ReportToCreate', reportType, 'ReportOutputFile', ...
    reportName, 'ColumnsToReport', signalMetadata);

Input Arguments

collapse all

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'ReportToCreate','Compare Runs','ShortenBlockPath',true

Simulation Data Inspector pane to capture in the report.

  • 'Inspect Signals' –– Create a report of the information on the Inspect pane.

  • 'Compare Runs' –– Create a report of the information on the Compare pane.

Example: 'ReportToCreate','Inspect Signals'

Example: 'ReportToCreate','Compare Runs'

Folder where the report is saved. Specify the path to the folder where you want to save the report as a character vector.

Example: 'ReportOutputFolder','C:\Users\user1\Desktop'

File name for report.

Example: 'ReportOutputFile','MyReport.html'

File overwrite protection for the report. File overwrite protection prevents the Simulation Data Inspector from overwriting an existing file by appending the file name with a number that increments for subsequent reports. When you disable file overwrite protection, the Simulation Data Inspector overwrites the existing report file unless you specify a unique file name.

  • true enables file overwrite protection.

  • false disables file overwrite protection.

Example: 'PreventOverwritingFile',true

Example: 'PreventOverwritingFile',false

Signal metadata to include in report. By default, the Inspect Signals report includes the block path, name, line style and color, and data source parameters for each plotted signal. The Compare Runs report includes the signal name, absolute tolerance, relative tolerance, and maximum difference metadata by default.

Specify metadata to include as an array, using the enumeration class Simulink.sdi.SignalMetaData. For example, to include the name of the simulation run and signal name, create an array like signal_metadata:

signal_metadata = [Simulink.sdi.SignalMetaData.Run,...
                    Simulink.sdi.SignalMetaData.SignalName];

Then, specify ColumnsToReport as signal_metadata in the name-value pair:

Simulink.sdi.report('ColumnsToReport',signal_metadata)

The table summarizes the metadata available for Inspect Signals report.

Column ValueDescription
SignalName (default)Signal name
Line (default)Signal line style and color
SID

Simulink® identifier

For more information about SIDs, see Locate Diagram Components Using Simulink Identifiers

UnitsSignal measurement units
SigDataTypeSignal data type
SigSampleTimeMethod used to sample the signal
ModelName of the model that generated the signal
BlockNameName of the source block for the signal
BlockPath Path to the source block for the signal
PortIndex of the signal on the output port of its block
DimensionsDimensions of the matrix containing the signal
ChannelIndex of signal within matrix
RunName of the simulation run containing the signal
AbsTol Absolute tolerance for the signal
RelTol Relative tolerance for the signal
OverrideGlobalTolProperty that specifies whether signal tolerances take priority over global tolerances
TimeTolTime tolerance for the signal
InterpMethodInterpolation method
SyncMethodSynchronization method used to coordinate signals for comparison
TimeSeriesRootName of the variable associated with the signal for signals imported from the MATLAB® workspace
TimeSourceName of the array containing the time data for signals imported from the MATLAB workspace
DataSourceName of the array containing the signal data for signals imported from the MATLAB workspace

The table provides a summary of the metadata available for the Compare Runs report.

Column ValueDescription
Result (default)Pass/fail result of the signal comparison between the Baseline and Compare To runs
Line1Line style and color for the Baseline signal
Line2Line style and color for the Compare To signal
AbsTol (default)Absolute tolerance for the Baseline signal
RelTol (default)Relative tolerance for the Baseline signal
MaxDifferenceThe maximum difference between the Baseline and Compare To signals
OverrideGlobalTolProperty that specifies whether the Baseline signal tolerances take priority over global tolerances
TimeTolTime tolerance for the Baseline signal
SignalName1Signal name from the Baseline run
SignalName2Signal name from the Compare To run
Units1Measurement units for the signal in the Baseline run
Units2Measurement units for the signal in the Compare To run
SigDataType1The data type for the signal in the Baseline run
SigDataType2The data type for the signal in the Compare To run
SigSampleTime1Method used to sample the signal in the Baseline run
SigSampleTime2Method used to sample the signal in the Compare To run
Run1Name of the Baseline run
Run2Name of the Compare To run
AlignedBy (default)Signal alignment method used to correlate Baseline and Compare To signals
Model1Name of the model that generated the Baseline signals
Model2Name of the model that generated the Compare To signals
BlockName1Name of the source block for the Baseline signal
BlockName2Name of the source block for the Compare To signal
BlockPath1Path to the source block for the Baseline signal
BlockPath2Path to the source block for the Compare To signal
Port1Index of the Baseline signal on the output port of its block
Port2Index of the Compare To signal on the output port of its block
Dimensions1Dimensions of the matrix containing the Baseline signal
Dimensions2Dimensions of the matrix containing the Compare To signal
Channel1Index of the Baseline within its matrix
Channel2Index of the Compare To within its matrix
InterpMethodInterpolation method for the Baseline signal
SyncMethodSynchronization method for the Baseline signal
TimeSeriesRoot1Name of the variable associated with the Baseline signal for signals imported from the MATLAB workspace
TimeSeriesRoot2Name of the variable associated with the Compare To signal for signals imported from the MATLAB workspace
TimeSource1Name of the array containing the Baseline time data for signals imported from the MATLAB workspace
TimeSource2Name of the array containing the Compare To time data for signals imported from the MATLAB workspace
DataSource1Name of the array containing the Baseline signal data for signals imported from the MATLAB workspace
DataSource2Name of the array containing the Compare To signal data for signals imported from the MATLAB workspace
LinkToPlot (default)Link to a plot of each comparison result

Example: 'ColumnsToReport',metadata

Block path length.

  • true –– Report shortened block path length.

  • false –– Include the full block path in the report.

Example: 'ShortenBlockPath',false

Open report when created.

  • true –– Open the report when it is created.

  • false –– Do not open the report upon creation.

Example: 'LaunchReport',false

Signals to include in a Compare Runs report.

  • ReportOnlyMismatchedSignals –– Include only signals that fall out of tolerance.

  • ReportAllSignals –– Include all signals.

Example: 'SignalsToReport','ReportAllSignals'

Introduced in R2011b