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 slreadtext
Home > sltoolbox > fileio > slreadtext.m

slreadtext

PURPOSE ^

SLREADTEXT Reads in a text file into a cell array

SYNOPSIS ^

function T = slreadtext(filename)

DESCRIPTION ^

SLREADTEXT Reads in a text file into a cell array

 $ Syntax $
   T = slreadtext(filename)

 $ Description $
   - T = slreadtext(filename) Reads in a text file to a cell array with
     each cell storing a line string. 

 $ Remarks $
   1. No extra operations will be performed on the strings besides deleting
      the trailing spaces in end of lines.

 $ History $
   Created by Dahua Lin, on 2005-06-02

CROSS-REFERENCE INFORMATION ^

This function calls:
This function is called by:
  • edl_readenvvars EDL_READENVVARS Reads in a file with environment variables
  • slcountlines SLCOUNTLINES Count the lines of m-files in a folder and make a report

SOURCE CODE ^

0001 function T = slreadtext(filename)
0002 %SLREADTEXT Reads in a text file into a cell array
0003 %
0004 % $ Syntax $
0005 %   T = slreadtext(filename)
0006 %
0007 % $ Description $
0008 %   - T = slreadtext(filename) Reads in a text file to a cell array with
0009 %     each cell storing a line string.
0010 %
0011 % $ Remarks $
0012 %   1. No extra operations will be performed on the strings besides deleting
0013 %      the trailing spaces in end of lines.
0014 %
0015 % $ History $
0016 %   Created by Dahua Lin, on 2005-06-02
0017 %
0018 
0019 fid = fopen(filename, 'r');
0020 if (fid <= 0)
0021     error(['Fail to open file ', filename]);
0022 end
0023 
0024 T = {};
0025 icount = 0;
0026 strline = fgets(fid);
0027 while ~isequal(strline, -1)
0028     icount = icount + 1;
0029     T{icount, 1} = deblank(strline);
0030     strline = fgets(fid);
0031 end
0032 
0033 fclose(fid);

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

Contact us at files@mathworks.com