MATLAB Function Reference |
Read line from file, discarding newline character
Syntax
Description
tline = fgetl(fid)
returns the next line of the file associated with the file identifier fid
. If fgetl
encounters the end-of-file indicator, it returns -1
. (See fopen
for a complete description of fid
.) fgetl
is intended for use with text files only.
The returned string tline
does not include the line terminator(s) with the text line. To obtain the line terminators, use fgets
.
Remarks
When reading character strings from files, pass the output of fgetl
to the MATLAB native2unicode
function to ensure that characters display correctly:
Examples
The example reads every line of the M-file fgetl.m
.
fid=fopen('fgetl.m'); while 1 tline = fgetl(fid); if ~ischar(tline), break, end disp(tline) end fclose(fid);
See Also
fftw | fgets |
© 1994-2005 The MathWorks, Inc.