Class: sdo.requirements.RelationalConstraint
Package: sdo.requirements
Evaluate satisfaction of relational constraint requirement
evaluation = evalRequirement(requirement,variableData1,variableData2)
evaluates
whether the test data from two variables, evaluation
= evalRequirement(requirement
,variableData1,variableData2
)variableData1
and variableData2
,
satisfy the relational constraint that is specified in the requirement
object.
requirement
— Relational constraint requirementsdo.requirements.RelationalConstraint
objectRelational constraint requirement, specified as an sdo.requirements.RelationalConstraint
object.
In the object, you specify the relation required between the elements
of two variables.
variableData1,variableData2
— Variable data to be evaluatedVariable data from the two variables to be evaluated, specified as real numeric vectors or arrays. The test data of the two variables must be the same size.
evaluation
— Evaluation of the relational constraint requirementEvaluation of the relational constraint requirement, returned
as a vector or array of the same size as the dimensions of the test
data variableData1
. Note that size of variableData1
and variableData2
is
the same.
Each element in evaluation
indicates whether
the corresponding elements in variableData1
and variableData2
satisfy
the requirement. The value returned for each element of evaluation
depends
on the relation specified in the requirement object:
requirement.Type | evaluation Value When Requirement
is Satisfied | evaluation Value
When Requirement is Violated |
---|---|---|
'>' or '<' | Negative number with magnitude |v1-v2| ,
the absolute value of difference between the elements v1 and v2 of variableData1 and variableData2 . | Positive number with magnitude |v1-v2| ,
or 0 if the elements are equal. |
'>=' or '<=' | Negative number with magnitude |v1-v2| ,
or 0 if the elements are equal. | Positive number with magnitude |v1-v2| . |
'==' | 0 | Non-zero number that is the difference between the two elements, v1-v2 . |
'~=' | 0 | 1 |
Create a requirement object, and specify that the elements of the first variable should be greater than elements of the second variable.
Requirement = sdo.requirements.RelationalConstraint('Type','>');
Specify test data for the two variables. The test data for both variables must be the same size.
varData1 = [20 -3 7]; varData2 = [20 -1 6];
Evaluate whether the test data satisfy the requirement.
Evaluation = evalRequirement(Requirement,varData1,varData2)
Evaluation = 1×3
0.0000 2.0000 -1.0000
Evaluation
is always the same size as the test data. When the relation type is specified as '>', if the requirement is satisfied, evalRequirement
returns a negative number with magnitude equal to the absolute value of difference between the two elements. If the requirement is violated, Evaluation
is a positive number with magnitude equal to the absolute value of the difference between the two elements, or 0
if the elements are equal.
The first elements of the two variables are equal, so the requirement is violated and Evaluation(1)
is 0
, the difference between the elements.
The second elements, -3 and -1, violate the requirement, resulting in a positive Evaluation(2)
with value = abs(-3-(-1))= 2.
The third elements, 7 and 6, satisfy the requirement, resulting in a negative Evaluation(3)
with value = -abs(7-6)= -1.
Create a requirement object, and specify that the elements of two variables should be equal to each other.
Requirement = sdo.requirements.RelationalConstraint('Type','==');
Specify test data for the two variables.
varData1 = [20 15]; varData2 = [20 55];
Evaluate whether the test data satisfies the requirement.
Evaluation = evalRequirement(Requirement,varData1,varData2)
Evaluation = 1×2
0 -40
Evaluation
is the same size as the test data. When the relation type is specified as '==', if the requirement is satisfied, evalRequirement
returns 0
, the difference between the elements. If the requirement is violated, Evaluation
is a non-zero number equal to the difference between the two elements.
The first elements of the two variables are equal, so the requirement is satisfied and Evaluation(1)
is 0
.
The second elements, 15 and 55, violate the requirement, resulting in a non-zero Evaluation(2)
.
You have a modified version of this example. Do you want to open this example with your edits?