%% Evaluate Elliptical Bound on Phase Plane Trajectory
% Create a default requirement object.

Requirement = sdo.requirements.PhasePlaneEllipse;

% The requirement object specifies the bounding ellipse as an upper bound with center located at [0,0], and no rotation. The x-axis radius of the ellipse is 1 and a y-axis radius is 0.5.
%
% Specify the test signal data as timeseries objects.

signal1 = timeseries(1-exp(-(0:10)'));
signal2 = timeseries(sin((0:10)'));

%
% Evaluate the requirement.

Evaluation = evalRequirement(Requirement,signal1,signal2)

%
% The default method for requirement evaluation, Requirement.Method is 'Maximum'. Thus, the evalRequirement command computes the signed minimum distance of each point in the phase plane trajectory to the bounding ellipse and then returns the maximum of these distances. A positive value indicates that the at least one point on the phase trajectory lies outside the ellipse and violates the requirement.
% To see the signed distance of each of the points on the trajectory to the phase plane ellipse, specify the method for evaluation as 'Residuals'.

Requirement.Method = 'Residuals';

%
% Evaluate the requirement using the new evaluation method.

Evaluation2 = evalRequirement(Requirement,signal1,signal2)

% Evaluation2 is the minimum distance of the phase plane trajectory to the bounding ellipse and is a column vector with length equal to the length of the signals.
% A negative value indicates that the phase plane trajectory of the two signals at the corresponding time point lies inside the ellipse and satisfies the requirement. A positive value indicates that the phase plane trajectory of the two signals at the corresponding time point lies outside the ellipse and violates the requirement.
% You can see that the maximum value in Evaluation2 is the same as Evaluation.
% Copyright 2012 The MathWorks, Inc.