www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@sweepsetfilter/char.m

    function B = char(A)
%CHAR Char converter for sweepsetfilter object
%
%  CHAR(SSF) returns a string that describes the object.

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


strName       = [' Name        : ' A.name];
strFilter     = i_CharFilter(A);
strVariable   = i_CharVariable(A);
strTFilter    = i_CharTFilter(A);
strTVariable  = i_CharTVariable(A);
strResampling = i_CharResampling(A);

B = char( strName, ...
    char(sweepset(A)), ...
    strFilter, ...
    strVariable, ...
    strTFilter, ...
    strTVariable, ...
    strResampling );



function strFilter = i_CharFilter(A)
if isempty(A.filters)
	strFilter = ' Filters        : ';
else
	[filters{1:length(A.filters)}] = deal(A.filters.filterExp);
	space = ' ';
    if length(A.filters)>1
        title = char(' Filters        : ', space(ones(length(A.filters)-1,1),:));
    else
        title = ' Filters        : ';
    end
	strFilter = [title char(filters)];
end



function strVariable = i_CharVariable(A)
if isempty(A.variables)
	strVariable = ' Variables      : ';
else
	[varName{1:length(A.variables)}] = deal(A.variables.varName);
    i = cellfun( 'isempty', varName );
    if any( i )
        [varName{i}] = deal( '<no name>' );
    end
    names = [' Variables      : ' varName{1}];
    if length(varName)>1
        names = char(names, char(varName(2:end)));
    end
	names = strjust(names, 'right');
	equals = repmat(' = ', size(names, 1), 1);
	[varExp{1:length(A.variables)}] = deal(A.variables.varExp);
    i = cellfun( 'isempty', varExp );
    if any( i )
        [varExp{i}] = deal( '<no expression>' );
    end
	strVariable = [names equals char(varExp)];
end



function strTFilter = i_CharTFilter(A)
if isempty(A.sweepFilters)
    strTFilter = ' Test Filters   : ';
else
    [Tfilters{1:length(A.sweepFilters)}] = deal(A.sweepFilters.filterExp);
    space = ' ';
    title = ' Test Filters   : ';
    if length(A.sweepFilters)>1
        title = char(title, space(ones(length(A.sweepFilters)-1,1),:));
    end
    strTFilter = [title char(Tfilters)];
end



function strTVariable = i_CharTVariable(A)
if isempty(A.sweepVariables)
    strTVariable = ' Test Variables : ';
else
    [TvarName{1:length(A.sweepVariables)}] = deal(A.sweepVariables.varName);
    names = [' Test Variables : ' TvarName{1}];
    if length(TvarName)>1
        names = char(names, char(TvarName(2:end)));
    end
    names = strjust(names, 'right');
    equals = repmat(' = ', size(names, 1), 1);
    [TvarExp{1:length(A.sweepVariables)}] = deal(A.sweepVariables.varExp);
    i = cellfun( 'isempty', TvarExp );
    if any( i ),
        [TvarExp{i}] = deal( '<no expression>' );
    end
    strTVariable = [names equals char(TvarExp)];
end



function strResampling = i_CharResampling(A)
if isempty( A.resampling.resampleExp ),
	strResampling = ' Resampling     : ';
else
    names = A.resampling.varNames;
    for i = 1:length( names ),
        if isempty( names{i} ),
            names{i} = '<empty variables>';
        elseif iscell( names{i} ),
            fmt = repmat( 'out.%s,', size( names{i} ) );
            fmt = sprintf( '[%s]', fmt(1:end-1) );
            names{i} = sprintf( fmt, names{i}{:} );
        else
            names{i} = sprintf( 'out.%s', names{i} );
        end
    end
    leftHandSide = 'Resampling     : ';
    nLeftHandSide = length( leftHandSide );
    names = char( names{:} );
    names = strjust(names, 'right');
    es = find(~isspace( names(1,:)), 1);
    if es < nLeftHandSide,
        b = repmat( ' ', size( names, 1 ), nLeftHandSide-es );
        names = [b, names];
    end
    names(1,1:nLeftHandSide) = leftHandSide;
    space = repmat( ' ', size(names, 1), 1 );
    equals = repmat(' = ', size(names, 1), 1);
    resampleExp = A.resampling.resampleExp;
    ind = cellfun( 'isempty', resampleExp );
    if any( ind ),
        [resampleExp{ind}] = deal( '<empty expression>' );
    end
    strResampling = [space, names, equals, char( resampleExp )];
end