www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xregexportmodel/ceval.m

    function c = ceval( m, x )
%CEVAL Constraint model evaluation
%    C = CEVAL( MODEL, X ) evaluates the constraints at X.  X is a (N-by-NF)
%    array, where NF is the number of inputs, and N the number of points to
%    evaluate the model at.  C<0 indicates the point is inside the
%    constraint.

%  Copyright 2000-2011 The MathWorks, Inc. and Ford Global Technologies, Inc.

% check the number of inputs and outputs
narginchk(2,2);
nargoutchk(0,1);

Xg = xregexportmodel.convertToDouble(x);

cmodel = m.constraints;
if ~isempty( cmodel)
    c = constraintDistance( cmodel, Xg );
else
    c = -ones(size(Xg,1),1);
end