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

    function str = toString(cif, tex)
%TOSTRING Convert constraint input factor object into a cell-string
%
%  STR = TOSTRING(CIF)
%  STR = CHAR(CIF, TEX)
%
%  See also CONBASE, CONINPUTFACTOR.

%  Copyright 2004-2008 The MathWorks, Inc.

NF = length( cif.Name );

%      'Name (symbol) [unit] [min, max]'
FMT_FULL = '%s (%s) [%s] [%g, %g]';

%           'Name [unit] [min, max]'
FMT_NOSYMBOL = '%s [%s] [%g, %g]';

if nargin < 2,
    tex = false;
end

str = cell( NF, 1 );
for i = 1:NF,
    if isempty( cif.Symbol{i} ) || strcmp(cif.Name{i},cif.Symbol{i})
        str{i} = sprintf( FMT_NOSYMBOL, cif.Name{i}, i_unit( cif.Unit{i} ), ...
            cif.Min(i), cif.Max(i) );
    else
        str{i} = sprintf( FMT_FULL, cif.Name{i}, cif.Symbol{i}, ...
            i_unit( cif.Unit{i} ), ...
            cif.Min(i), cif.Max(i) );
    end
end

if tex,
    str = detex( str );
end

%------------------------------------------------------------------------------|
function str = i_unit( str )
if isempty( str ) || strcmp( str, '?' ),
    str = '-';
end

%------------------------------------------------------------------------------|
% EOF
%------------------------------------------------------------------------------|