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

    function str = getFullNames(cif, tex)
%GETFULLNAMES Get name, symbols and units in user friendly strings
%
%  GETFULLNAMES(CIF) is a cell array where each element is a string with
%  the name, symbol and unit for the corresponding input factor.
%
%  See also CONBASE, CONINPUTFACTOR, 
%           CONINPUTFACTOR/TOSTRING.

%  Copyright 2005-2008 The MathWorks, Inc.

NF = length( cif.Name );

%      'Name (symbol) [unit]'
FMT_FULL = '%s (%s) [%s]';

%           'Name [unit] '
FMT_NOSYMBOL = '%s [%s]';

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} ) );
    else
        str{i} = sprintf( FMT_FULL, cif.Name{i}, cif.Symbol{i}, ...
            i_unit( cif.Unit{i} ) );
    end
end

if tex,
    str = detex( str );
end

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

%--------------------------------------------------------------------------
% EOF
%--------------------------------------------------------------------------