getResultsByName
Description
returns the signal comparison result for the signal named diffSig
= getResultsByName(diffRes
,sigName
)sigName
in the
run comparison results object diffRes
.
The output of the function getResultsByName
depends on the signal
that is being compared.
If the result that corresponds to
sigName
is a real, scalar signal, thendiffSig
is aSimulink.sdi.DiffSignalResult
object.If the result that corresponds to
sigName
is a complex signal, a multidimensional signal, or a bus, thendiffSig
is an array ofSimulink.sdi.DiffSignalResult
objects. The size of the array corresponds to characteristics of the comparison result.
Examples
Get Comparison Results By Name
Load the Simulation Data Inspector session file getResultsByNameData
. The file contains data logged from two simulations of the model getResultsByNameModel
, which logs data for five signals.
Simulink.sdi.load("getResultsByNameData.mldatx");
Access the run IDs for the two runs loaded from the file.
runIDs = Simulink.sdi.getAllRunIDs; baselineID = runIDs(end-1); comparedToID = runIDs(end);
Compare the two runs.
diffResult = Simulink.sdi.compareRuns(baselineID,comparedToID);
Use the function getResultsByName
to access comparison results for the signal ScalarOut
.
compareSig = getResultsByName(diffResult,"ScalarOut")
compareSig = DiffSignalResult with properties: Name: 'ScalarOut' Status: WithinTolerance AlignBy: 'Path' SignalID1: 4847 SignalID2: 4927 MaxDifference: 0 Sync1: [1x1 timeseries] Sync2: [1x1 timeseries] Diff: [1x1 timeseries]
Get Comparison Results for Complex Signal
Load the Simulation Data Inspector session file getResultsByNameData
. The file contains data logged from two simulations of the model getResultsByNameModel
, which logs data for five signals, including the complex signal ComplexOut
.
Simulink.sdi.load("getResultsByNameData.mldatx");
Access the run IDs for the two runs loaded from the file.
runIDs = Simulink.sdi.getAllRunIDs; baselineID = runIDs(end-1); comparedToID = runIDs(end);
Compare the two runs.
diffResult = Simulink.sdi.compareRuns(baselineID,comparedToID);
Use the function getResultsByName
to access comparison results for the complex signal ComplexOut
.
compareComplex = getResultsByName(diffResult,"ComplexOut")
compareComplex=1×2 DiffSignalResult array with properties:
Name
Status
AlignBy
SignalID1
SignalID2
MaxDifference
Sync1
Sync2
Diff
Options
You can also use the function getResultsByName
to access comparison results for the real or imaginary parts of the signal by specifying (real)
or (imag)
as part of the signal name.
compareComplexReal = getResultsByName(diffResult,"ComplexOut (real)")
compareComplexReal = DiffSignalResult with properties: Name: 'ComplexOut (real)' Status: WithinTolerance AlignBy: 'Path' SignalID1: 1647 SignalID2: 1727 MaxDifference: 0 Sync1: [1x1 timeseries] Sync2: [1x1 timeseries] Diff: [1x1 timeseries]
Get Comparison Results for Nonscalar Signal
Load the Simulation Data Inspector session file getResultsByNameData
. The file contains data logged from two simulations of the model getResultsByNameModel
, which logs data for five signals, including two multidimensional signals: SmallMux
and LargeMux
.
Simulink.sdi.load("getResultsByNameData.mldatx");
Access run IDs for the two runs loaded from the file.
runIDs = Simulink.sdi.getAllRunIDs; baselineID = runIDs(end-1); comparedToID = runIDs(end);
Compare the two runs.
diffResult = Simulink.sdi.compareRuns(baselineID,comparedToID);
Use the function getResultsByName
to access comparison results for LargeMux
and SmallMux
. By default, when you compare runs that contain signals with multidimensional sample values, the Simulation Data Inspector expands the signal to channels and compares the channels. For more information, see Analyze Multidimensional Signal Data.
compareLargeMux = getResultsByName(diffResult,"LargeMux")
compareLargeMux=1×5 DiffSignalResult array with properties:
Name
Status
AlignBy
SignalID1
SignalID2
MaxDifference
Sync1
Sync2
Diff
Options
compareSmallMux = getResultsByName(diffResult,"SmallMux")
compareSmallMux=1×2 DiffSignalResult array with properties:
Name
Status
AlignBy
SignalID1
SignalID2
MaxDifference
Sync1
Sync2
Diff
Options
You can access comparison results for an element within a multidimensional signal using the index of the element within the logged signal. For example, get comparison results for the fourth element of the LargeMux
signal.
compareElement = compareLargeMux(4)
compareElement = DiffSignalResult with properties: Name: 'LargeMux(4)' Status: WithinTolerance AlignBy: 'Path' SignalID1: 4407 SignalID2: 4411 MaxDifference: 0 Sync1: [1x1 timeseries] Sync2: [1x1 timeseries] Diff: [1x1 timeseries]
Get Comparison Results for Bus
Load the Simulation Data Inspector session file getResultsByNameData
. The file contains data logged from two simulations of the model getResultsByNameModel
, which logs data for five signals, including a bus.
Simulink.sdi.load("getResultsByNameData.mldatx");
Access the run IDs for the two runs loaded from the file.
runIDs = Simulink.sdi.getAllRunIDs; baselineID = runIDs(end-1); comparedToID = runIDs(end);
Compare the two runs.
diffResult = Simulink.sdi.compareRuns(baselineID,comparedToID);
Use the function getResultsByName
to access the comparison results for BusOut
.
compareBus = getResultsByName(diffResult,"BusOut")
compareBus=1×4 DiffSignalResult array with properties:
Name
Status
AlignBy
SignalID1
SignalID2
MaxDifference
Sync1
Sync2
Diff
Options
You can also get comparison results for bus elements. Use the function getResultsByName
to access the comparison results for the signal Constant 4
inside the bus BusOut
.
compareConst4 = getResultsByName(diffResult,"BusOut.Constant_4")
compareConst4 = DiffSignalResult with properties: Name: 'BusOut.Constant_4' Status: WithinTolerance AlignBy: 'Path' SignalID1: 37 SignalID2: 117 MaxDifference: 0 Sync1: [1x1 timeseries] Sync2: [1x1 timeseries] Diff: [1x1 timeseries]
Input Arguments
diffRes
— Run comparison results
Simulink.sdi.DiffRunResult
object
Run comparison results that contain the signal result you want to access, specified
as a Simulink.sdi.DiffRunResult
object.
sigName
— Name of signal result in run comparison results
string | character vector
Name of the signal in the run comparison results, specified as a character vector or string.
To access a bus element, specify the path to the element through the hierarchy of
the bus. For example, to access comparison results for the signal
Sine
inside the bus BusOut
, specify
sigName
as "BusOut.Sine"
.
sineRes = getResultsByName(diffRes,"BusOut.Sine");
To access only the real or imaginary result for a complex signal, append the signal
name with either (real)
or (imag)
. For example, to
access the comparison results for the imaginary part of the complex signal
ComplexOut
, specify sigName
as
"ComplexOut (imag)"
.
imagRes = getResultsByName(diffRes,"ComplexOut (imag)");
Data Types: char
| string
Output Arguments
diffSig
— Comparison results for specified name
Simulink.sdi.DiffSignalResult
object | array of Simulink.sdi.DiffSignalResult
objects
Comparison results for specified name, returned as a Simulink.sdi.DiffSignalResult
object or an array of Simulink.sdi.DiffSignalResult
objects.
The type of output returned by getResultsByName
depends on the
sigName
input.
sigName Input | diffSig Result |
---|---|
Uniquely named scalar signal |
|
One of N scalar signals with the same name |
|
Complex signal |
|
Vector or matrix signal with N elements |
|
Bus |
|
Note
If you specify a name for sigName
that is not in the run
comparison results, then the function returns an empty array.
Version History
Introduced in R2022b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)