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: 4872 SignalID2: 4952 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: 1661 SignalID2: 1741 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: 4432 SignalID2: 4436 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 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
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)