|MATLAB Function Reference|
Read line from file, keeping newline character
tline = fgets(fid)
returns the next line of the file associated with file identifier
fgets encounters the end-of-file indicator, it returns
fopen for a complete description of
fgets is intended for use with text files only.
The returned string
tline includes the line terminators associated with the text line. To obtain the string without the line terminators, use
tline = fgets(fid, nchar)
returns at most
nchar characters of the next line. No additional characters are read after the line terminators or an end-of-file.
When reading character strings from files, pass the output of
fgets to the MATLAB
native2unicode function to ensure that characters display correctly:
© 1994-2005 The MathWorks, Inc.