www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgrangeconstraint/setUpperValueMode.m

    function obj = setUpperValueMode(obj, mode)
%SETUPPERVALUEMODE Set the current evaluation mode of the upper bound
%
%   OBJ = SETUPPERVALUEMODE(OBJ, MODE) sets the current right-hand side
%   mode of the upper bound constraint. 
%   If MODE = 'value' or MODE = 0, a constant will be used as the
%   constraint comparison.  
%   If MODE = 'internal' or MODE = 1, the internal lower bound vector will
%   be evaluated for the constraint comparison value.
%   If MODE = 'input' or MODE = 2, the second expression input will be
%   evaluated for the constraint comparison value.
%
%   See also CGRANGECONSTRAINT/SETUPPERRHSVALUE,
%   CGRANGECONSTRAINT/SETUPPEREVALUATIONMODE

%   Copyright 2006 The MathWorks, Inc.

% Set the mode of the upper bound constraint
modeForExprCon = pInternalToExprCon(mode);
obj.UpperBound.info = setvaluemode(obj.UpperBound.info, modeForExprCon);

% If internal vector specified, then set the lower expression to be the
% internal pointer
if mode == 1
    obj.UpperBound.info = setrhsexpr(obj.UpperBound.info, obj.pMaxVector);
    % Expr constraints support the evaluation of a boundary constraint of a
    % variable. Disallow for range constraints.
    obj.UpperBound.info = setevaluationmode(obj.UpperBound.info, [], 0);
end

% If external expression specified and current expression is the internal
% vector, then set the lower bound expression to be null
pExpr = getrhsexpr(obj.UpperBound.info);
if mode == 2 && pExpr == obj.pMaxVector
    obj.UpperBound.info = setrhsexpr(obj.UpperBound.info, mbcpointer(1));
end