Code covered by the BSD License  

Highlights from
Statistical Learning Toolbox

from Statistical Learning Toolbox by Dahua Lin
Functions for statistical learning, pattern recognition and computer vision, covering many topics.

Description of addfiles
Home > sltoolbox > fileio > @sllog > addfiles.m

addfiles

PURPOSE ^

ADDFILES add a set of log files to the logger

SYNOPSIS ^

function logger = addfiles(logger, files, initstatus)

DESCRIPTION ^

ADDFILES add a set of log files to the logger

 $ Syntax $
   - logger = addfiles(logger, file)
   - logger = addfiles(logger, files)
   - logger = addfiles(logger, files, initstatus)

 $ Arguments $
   - logger:       the logger you want to add files to
   - file:         a string of a filename
   - files:        a cell array of filenames
   - initstatus:   whether is activated initially (default = true)

 $ Description $
   - logger = addfiles(logger, file) adds one file to logger
   
   - logger = addfiles(logger, files) adds a set of files to logger

   - logger = addfiles(logger, files, initstatus) additionally sets
     the initial states of the added files.

 $ Remarks $
   - Repeated filename cannot be added to the logger list.

   - The files will be open before adding, and the status will be
     initially set to true by default.

 $ History $
   - Created by Dahua Lin, on Aug 12th, 2006

CROSS-REFERENCE INFORMATION ^

This function calls:
  • addfiles ADDFILES add a set of log files to the logger
  • isattached ISATTACHED Judges whether the file is attached to the logger
  • sladdpath SLADDPATH Adds dirpath to precede the filenames
This function is called by:
  • edl_readexpdefs EDL_READEXPDEFS Reads in an experiment definition from XML file
  • addfiles ADDFILES add a set of log files to the logger
  • sllog SLLOG Constructs a logger

SOURCE CODE ^

0001 function logger = addfiles(logger, files, initstatus)
0002 %ADDFILES add a set of log files to the logger
0003 %
0004 % $ Syntax $
0005 %   - logger = addfiles(logger, file)
0006 %   - logger = addfiles(logger, files)
0007 %   - logger = addfiles(logger, files, initstatus)
0008 %
0009 % $ Arguments $
0010 %   - logger:       the logger you want to add files to
0011 %   - file:         a string of a filename
0012 %   - files:        a cell array of filenames
0013 %   - initstatus:   whether is activated initially (default = true)
0014 %
0015 % $ Description $
0016 %   - logger = addfiles(logger, file) adds one file to logger
0017 %
0018 %   - logger = addfiles(logger, files) adds a set of files to logger
0019 %
0020 %   - logger = addfiles(logger, files, initstatus) additionally sets
0021 %     the initial states of the added files.
0022 %
0023 % $ Remarks $
0024 %   - Repeated filename cannot be added to the logger list.
0025 %
0026 %   - The files will be open before adding, and the status will be
0027 %     initially set to true by default.
0028 %
0029 % $ History $
0030 %   - Created by Dahua Lin, on Aug 12th, 2006
0031 %
0032 
0033 if nargin < 3
0034     initstatus = true;
0035 else
0036     if ~islogical(initstatus) || numel(initstatus) ~= 1
0037         error('sltoolbox:invalidarg', ...
0038             'The initstatus should be a logical variable');
0039     end
0040 end
0041 
0042 
0043 if ischar(files)
0044         
0045     if isattached(logger, files)
0046         error('sltoolbox:invalidarg', ...
0047             'The file %s has been added to the file list', fp);
0048     end
0049                       
0050     fp = sladdpath(files, logger.rootpath);
0051     fid = fopen(fp, 'at');
0052     if fid <= 0
0053         error('sltoolbox:fileioerror', ...
0054             'Fail to open log file %s', fp);
0055     end
0056     
0057     curn = length(logger.files);
0058     idx = curn + 1;
0059     logger.files(idx, 1).filepath = fp;
0060     logger.files(idx, 1).fid = fid;
0061     logger.files(idx, 1).isactive = initstatus;
0062     
0063 elseif iscell(files)
0064     
0065     n = numel(files);
0066     for i = 1 : n
0067         logger = addfiles(logger, files{i}, initstatus);
0068     end
0069     
0070 else
0071     error('sltoolbox:invalidarg', ...
0072         'The files should be either a filename or a cell array of filenames');
0073 end
0074 
0075     
0076     
0077     
0078

Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003

Contact us at files@mathworks.com