Main Content

verifySignalsMatch

R2026b

Class: sltest.TestCase
Namespace: sltest

Verify two sets of data are equivalent

Description

verifySignalsMatch(testCase,actual,expected) verifies that the actual and expected signal data values are equivalent. When a verification fails, the failure is recorded and the test runs to completion. For more information, see matlab.unittest.qualifications.Verifiable.

example

verifySignalsMatch(___,diagnostic) returns diagnostic information when the actual and expected data values are not equivalent.

example

verifySignalsMatch(___,Name=Value) filters test content with additional options specified by one or more Name=Value pair arguments.

example

Input Arguments

expand all

Instance of the test case, specified as an sltest.TestCase object.

Actual values to compare to expected values, specified as time series data, a string, or character array. The data for each actual value must pair data value with time value. The data must be in a format supported by the Simulation Data Inspector. The Simulation Data Inspector requires data in a format that associates sample values with time. Supported formats include timeseries, Structure with time, and Dataset.

Example: 'C:/matlab/data/actualData.mat'

Expected values to use as the baseline for the comparison. The data for each expected value must pair data value with time value. The data must be in a format supported by the Simulation Data Inspector. The Simulation Data Inspector requires data in a format that associates sample values with time. Supported formats include timeseries, Structure with time, and Dataset.

Example: 'C:/matlab/data/expectedData.mat'

Diagnostic information to display when the verification that the actual and expected values are equivalent fails, specified as a string, character array, a function handle, or an instance of a matlab.automation.diagnostics.Diagnostic class.

Example: 'Simulation output does not match.'

Name-Value Arguments

expand all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: AbsTol=.02

In addition to the listed Name-Value pairs, you can use the Simulink.sdi.constraints.MatchesSignal Name-Value pairs.

Absolute tolerance, specified as the name-value argument consisting of AbsTol and the scalar value of the tolerance. The tolerance specifies the magnitude of the difference between the actual and expected values.

Example: AbsTol=1e-9

Relative tolerance, specified as the name-value argument consisting of RelTol and the scalar value of the tolerance. The relative tolerance specifies the magnitude of the difference between the actual and expected values, relative to the expected value.

Example: RelTol=.002

Time tolerance, specified as the name-value argument consisting of TimeTol and the scalar value of the tolerance.

Example: TimeTol=.2

Attributes

Accesspublic
Sealedtrue

To learn about attributes of methods, see Method Attributes.

Examples

expand all

Create a test case for interactive use. Then, simulate the model in normal mode to obtain the expected values, and simulate in rapid accelerator mode to obtain the actual values. Use verifySignalsMatch to compare the values.

testCase =...
   sltest.TestCase.forInteractiveUse;
 
expected = testCase.simulate('myModel',...
   SimulationMode='Normal');
actual = testCase.simulate('myModel',...
   SimulationMode='Rapid-Accelerator');
 
testCase.verifySignalsMatch(actual,expected)

Create a test case for interactive use. Simulate the model in rapid accelerator mode to obtain the actual values. Use verifySignalsMatch to compare the actual values to the baseline values saved in a MAT file. Set a relative tolerance.

testCase =...
   sltest.TestCase.forInteractiveUse;
 
actual = testCase.simulate('myModel',...
   SimulationMode='Rapid-Accelerator');

testCase.verifySignalsMatch(actual,'baseline.mat',...
   RelTol=0.001) 

Create a test case for interactive use. Then, simulate the model in rapid accelerator mode to obtain the actual values. Use verifySignalsMatch to compare the actual values to the baseline values saved in a MAT file. Specify the diagnostic message to display if the verification fails.

testCase =...
   sltest.TestCase.forInteractiveUse;
 
actual = testCase.simulate('myModel',...
   SimulationMode='Rapid-Accelerator');
 
testCase.verifySignalsMatch(actual,'baseline.mat',...
   'Rapid-Accel output did not match.')
 

Version History

Introduced in R2020b