www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@conlinear/tostring.m

    function ch=tostring(c)
%TOSTRING Create string representation of constraint
%
%  STR=TOSTRING(CON) returns a string the describes the constraint.
%
%  See also CONLINEAR.

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

fact = getActiveFactors( c );
s = [num2cell(c.A) ; getSymbols( fact )];
s = s(:,c.A~=0);
if ~isempty(s)
    s = sprintf('%g*%s + ',s{:});
    s = strrep(s,'+ -','- ');
else
    % There are no non-zero coefficients.  Instead of having a blank lhs,
    % just print "0".
    s = '0 + ';
end
% 'Aij*xj + ... <= bi'
ch = [s(1:end-2) sprintf('<= %g',c.b)];