Generate a Simulation Data Inspector report
Simulink.sdi.report
creates a Simulation Data Inspector
report of the plotted data in the Inspect pane of the
Simulation Data Inspector.
Simulink.sdi.report(
uses
additional options specified by one or more Name,Value
)Name,Value
pair
arguments to generate a report of the specified view in the Simulation Data
Inspector.
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);
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
.
'ReportType','Compare','ShortenBlockPath',true
'ReportType'
— Type of report to create'Inspect'
(default) | 'Compare'
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'
'ReportStyle'
— Style of report to generate'Printable'
(default) | 'Interactive'
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'
'ReportOutputFolder'
— Folder where report is saved<current working
folder>/sdireports
(default) | path
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'
'ReportOutputFile'
— Report file name'SDI_report.html'
(default) | character vectorFile name for report, specified as the comma-separated pair consisting
of 'ReportOutputFile'
and a character vector.
Example: 'ReportOutputFile','MyReport.html'
'PreventOverwritingFile'
— Whether to prevent overwriting report filestrue
(default) | false
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
'ColumnsToReport'
— Signal metadata to include in reportSignal 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 Value | Description |
---|---|
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 |
Units | Signal measurement units |
SigDataType | Signal data type |
SigSampleTime | Method used to sample the signal |
Model | Name of the model that generated the signal |
BlockName | Name of the source block for the signal |
BlockPath
| Path to the source block for the signal |
Port | Index of the signal on the output port of its block |
Dimensions | Dimensions of the matrix containing the signal |
Channel | Index of signal within matrix |
Run | Name of the simulation run containing the signal |
AbsTol
| Absolute tolerance for the signal |
RelTol
| Relative tolerance for the signal |
OverrideGlobalTol | Property that specifies whether signal tolerances take priority over global tolerances |
TimeTol | Time tolerance for the signal |
InterpMethod | Interpolation method |
SyncMethod | Synchronization method used to coordinate signals for comparison |
TimeSeriesRoot | Name of the variable associated with the signal for signals imported from the MATLAB® workspace |
TimeSource | Name of the array containing the time data for signals imported from the MATLAB workspace |
DataSource | Name 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 Value | Description |
---|---|
Result (default) | Pass/fail result of the signal comparison between the Baseline and Compare To runs |
Line1 | Line style and color for the Baseline signal |
Line2 | Line style and color for the Compare To signal |
AbsTol (default) | Absolute tolerance for the Baseline signal |
RelTol (default) | Relative tolerance for the Baseline signal |
MaxDifference | The maximum difference between the Baseline and Compare To signals |
OverrideGlobalTol | Property that specifies whether the Baseline signal tolerances take priority over global tolerances |
TimeTol | Time tolerance for the Baseline signal |
SignalName1 | Signal name from the Baseline run |
SignalName2 | Signal name from the Compare To run |
Units1 | Measurement units for the signal in the Baseline run |
Units2 | Measurement units for the signal in the Compare To run |
SigDataType1 | The data type for the signal in the Baseline run |
SigDataType2 | The data type for the signal in the Compare To run |
SigSampleTime1 | Method used to sample the signal in the Baseline run |
SigSampleTime2 | Method used to sample the signal in the Compare To run |
Run1 | Name of the Baseline run |
Run2 | Name of the Compare To run |
AlignedBy (default) | Signal alignment method used to correlate Baseline and Compare To signals |
Model1 | Name of the model that generated the Baseline signals |
Model2 | Name of the model that generated the Compare To signals |
BlockName1 | Name of the source block for the Baseline signal |
BlockName2 | Name of the source block for the Compare To signal |
BlockPath1 | Path to the source block for the Baseline signal |
BlockPath2 | Path to the source block for the Compare To signal |
Port1 | Index of the Baseline signal on the output port of its block |
Port2 | Index of the Compare To signal on the output port of its block |
Dimensions1 | Dimensions of the matrix containing the Baseline signal |
Dimensions2 | Dimensions of the matrix containing the Compare To signal |
Channel1 | Index of the Baseline within its matrix |
Channel2 | Index of the Compare To within its matrix |
InterpMethod | Interpolation method for the Baseline signal |
SyncMethod | Synchronization method for the Baseline signal |
TimeSeriesRoot1 | Name of the variable associated with the Baseline signal for signals imported from the MATLAB workspace |
TimeSeriesRoot2 | Name of the variable associated with the Compare To signal for signals imported from the MATLAB workspace |
TimeSource1 | Name of the array containing the Baseline time data for signals imported from the MATLAB workspace |
TimeSource2 | Name of the array containing the Compare To time data for signals imported from the MATLAB workspace |
DataSource1 | Name of the array containing the Baseline signal data for signals imported from the MATLAB workspace |
DataSource2 | Name 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
'ShortenBlockPath'
— Whether to shorten block path in reporttrue
(default) | false
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
'LaunchReport'
— Whether to open report when createdtrue
(default) | 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
'SignalsToReport'
— Signals to include in comparison report'ReportOnlyMismatchedSignals'
(default) | 'ReportAllSignals'
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'
Simulink.sdi.Signal
| Simulink.sdi.compareRuns
| Simulink.sdi.compareSignals
| Simulink.sdi.createRun
You have a modified version of this example. Do you want to open this example with your edits?