www.gusucode.com > mbcexpr 工具箱 matlab 源码程序 > mbcexpr/@cgexprconstraint/updateranges.m
function obj = updateranges(obj) %UPDATERANGES Update the input ranges that are used for the constraint % % OBJ = UPDATERANGES(OBJ) recalculates the input ranges that are used to % appropriately scale the constraint output. % Copyright 2005 The MathWorks, Inc. and Ford Global Technologies, Inc. ptrs = getinputs(obj); isok = isvalid(ptrs); nInp = length(ptrs); % LHS Range if nInp>0 && isok(1) % Range of value expression Rlhs = ptrs(1).getcommonrange; else Rlhs = [0 0]; end % RHS Range if obj.ExprEvalFunc==1 % RHS is 0 Rrhs = [0 0]; elseif obj.CompValueType==1 && nInp>1 && isok(2) % Get range of comparison expression - use interquartile to try to % mitigate optim scaling issues. Rrhs = ptrs(2).getcommonrange; elseif obj.CompValueType==0 % Constant Rrhs = [obj.CompValue, obj.CompValue]; else Rrhs = [0 0]; end % scale is max distance between range edges of each side. To get this we % only need to compare whether max_A-min_B is bigger than max_B-min_A. sc = max(abs(Rrhs(1)-Rlhs(2)), abs(Rlhs(1)-Rrhs(2))); % Don't allow a zero scaling coefficient if sc==0 sc = 1; end obj.DistanceScale = sc;