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
sigNameis a real, scalar signal, thendiffSigis aSimulink.sdi.DiffSignalResultobject.If the result that corresponds to
sigNameis a complex signal, a multidimensional signal, or a bus, thendiffSigis an array ofSimulink.sdi.DiffSignalResultobjects. The size of the array corresponds to characteristics of the comparison result.
Examples
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: 5254
SignalID2: 5334
MaxDifference: 0
Sync1: [1×1 timeseries]
Sync2: [1×1 timeseries]
Diff: [1×1 timeseries]
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: 1928
SignalID2: 2008
MaxDifference: 0
Sync1: [1×1 timeseries]
Sync2: [1×1 timeseries]
Diff: [1×1 timeseries]
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: 4360
SignalID2: 4364
MaxDifference: 0
Sync1: [1×1 timeseries]
Sync2: [1×1 timeseries]
Diff: [1×1 timeseries]
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: 234
SignalID2: 314
MaxDifference: 0
Sync1: [1×1 timeseries]
Sync2: [1×1 timeseries]
Diff: [1×1 timeseries]
Input Arguments
Run comparison results that contain the signal result you want to access, specified
as a Simulink.sdi.DiffRunResult object.
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
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.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)