evalRequirement
Class: sdo.requirements.RelationalConstraint
Package: sdo.requirements
Evaluate satisfaction of relational constraint requirement
Syntax
evaluation = evalRequirement(requirement,variableData1,variableData2)
Description
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.
Input Arguments
requirement
— Relational constraint requirement
sdo.requirements.RelationalConstraint
object
Relational 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 evaluated
real numeric vectors | real numeric arrays
Variable 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.
Output Arguments
evaluation
— Evaluation of the relational constraint requirement
vector | array
Evaluation 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 |
Examples
Evaluate a Relational Constraint Requirement
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.
Evaluate Equality of Two Variables
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)
.
Version History
Abrir ejemplo
Tiene una versión modificada de este ejemplo. ¿Desea abrir este ejemplo con sus modificaciones?
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de 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)