%% 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 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.
% Copyright 2012 The MathWorks, Inc.