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 a report of signals plotted in the Simulation Data Inspector using the Simulink.sdi.report function. You can use the Simulink.sdi.report function to create a report that contains plotted signals in the Inspect pane or for comparison results. This example generates data by simulating a model, then shows how to create a report that contains information about the plotted signals and an image of the plotting area. To run the example exactly as shown, ensure that the Simulation Data Inspector repository starts empty using the Simulink.sdi.clear function.

Generate Data

This example generates data by simulating the model ex_sldemo_absbrake using a different desired slip ratio for each simulation.

Simulink.sdi.clear

load_system('ex_sldemo_absbrake')

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

% Specify 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 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 using the 'ColumnsToReport' name-value pair and the enumeration class Simulink.sdi.SignalMetaData. This example shows how to specify the metadata to include in the report programmatically.

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


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

Simulink.sdi.report('ReportType', 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: 'ReportType','Compare','ShortenBlockPath',true

Type of report to create, specified as the comma-separated pair consisting of 'ReportType' and 'Inspect' or 'Compare'.

  • 'Inspect' –– Create a report that contains the data and metadata for plotted signals in the Inspect pane.

  • 'Compare' –– Create a report that contains comparison results.

Example: 'ReportType','Compare'

Style of report to create, specified as the comma-separated pair consisting of 'ReportStyle' and 'Printable' or 'Interactive'.

  • 'Printable' –– Create a report that displays all plots and information inline.

    A printable report of the plotted signals on the Inspect pane has a table that contains the metadata for the plotted signals above an image of the plot area.

    A printable report of comparison results has a summary table that contains the signal results, followed by the individual signal results. Each individual signal result includes the summary information for the signal above the comparison plot.

  • 'Interactive' –– Create an interactive report that shows comparison results one at a time. You can select the results you want to view and easily view all signal metadata. For more information about the interactive comparison report, see Create an Interactive Comparison Report.

    Reports that include data on the Inspect pane do not support an interactive report option.

Example: 'ReportStyle','Interactive'

Folder where the report is saved, specified as the comma-separated pair consisting of 'ReportOutputFolder' and a character vector.

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

File name for report, specified as the comma-separated pair consisting of 'ReportOutputFile' and a character vector.

Example: 'ReportOutputFile','MyReport.html'

Whether to prevent overwriting report files, specified as the comma-separated pair consisting of 'PreventOverwritingFile' and true or false.

  • true enables file overwrite protection.

  • false disables file overwrite protection.

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.

Example: 'PreventOverwritingFile',false

Signal metadata to include in report, specified as the comma-separated pair consisting of 'ColumnsToReport' and an array. By default, the Inspect report includes the block path, name, line style and color, and data source parameters for each plotted signal. The Compare 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 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 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 in a printable comparison report

Example: 'ColumnsToReport',metadata

Whether to shorten block paths in the report, specified as the comma-separated pair consisting of 'ShortenBlockPath' and true or false.

  • true –– Use the shortened block path in the report.

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

Example: 'ShortenBlockPath',false

Whether to open the report when it is created, specified as the comma-separated pair consisting of 'LaunchReport' and true or false.

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

  • false –– Do not open the report automatically.

Example: 'LaunchReport',false

Signals to include in a comparison report, specified as the comma-separated pair consisting of 'SignalsToReport' and 'ReportOnlyMismatchedSignals' or 'ReportAllSignals'.

  • ReportOnlyMismatchedSignals –– Include only signals with out of tolerance comparison results.

  • ReportAllSignals –– Include all signals.

Example: 'SignalsToReport','ReportAllSignals'

Introduced in R2011b