www.gusucode.com > mbcexpr 工具箱 matlab 源码程序 > mbcexpr/@cgconconstraint/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 for
%  the constraint.  Having correct input ranges will mean multiple
%  constraints can be compared with each other. 

%  Copyright 2005 The MathWorks, Inc. and Ford Global Technologies, Inc.


cif = getInputFactors(obj.ConObject);
ptrs = getinputs(obj);
nf = length(ptrs);
isok = isvalid(ptrs);

Rok = cell(1, nf);
Rok(isok) = pveceval(ptrs(isok), @getrange);
Ranges = zeros(2, nf);
for n = 1:nf
    if isok(n)
        Ranges(:,n) = Rok{n}(:);
    else
        Ranges(:,n) = [0;100];
    end
end
cif = setRange(cif, Ranges);

obj.ConObject = setInputFactors(obj.ConObject, cif);