time | Calls | line |
---|
| | 1 | function tline = fgetl(fid)
|
| | 2 | %FGETL Read line from file, discard newline character.
|
| | 3 | % TLINE = FGETL(FID) returns the next line of a file associated with file
|
| | 4 | % identifier FID as a MATLAB character vector. The line terminator is NOT included.
|
| | 5 | % Use FGETS to get the next line with the line terminator INCLUDED. If just an
|
| | 6 | % end-of-file is encountered, -1 is returned.
|
| | 7 | %
|
| | 8 | % If an error occurs while reading from the file, FGETL returns an empty character
|
| | 9 | % vector. Use FERROR to determine the nature of the error.
|
| | 10 | %
|
| | 11 | % MATLAB reads characters using the encoding scheme associated with the file. See
|
| | 12 | % FOPEN for more information.
|
| | 13 | %
|
| | 14 | % FGETL is intended for use with files that contain newline characters. Given a
|
| | 15 | % file with no newline characters, FGETL may take a long time to execute.
|
| | 16 | %
|
| | 17 | % Example
|
| | 18 | % fid=fopen('fgetl.m');
|
| | 19 | % while 1
|
| | 20 | % tline = fgetl(fid);
|
| | 21 | % if ~ischar(tline), break, end
|
| | 22 | % disp(tline)
|
| | 23 | % end
|
| | 24 | % fclose(fid);
|
| | 25 | %
|
| | 26 | % See also FGETS, FOPEN, FERROR.
|
| | 27 |
|
| | 28 | % Copyright 1984-2016 The MathWorks, Inc.
|
| | 29 |
|
< 0.001 | 14 | 30 | narginchk(1,1)
|
| | 31 |
|
0.001 | 14 | 32 | [tline,lt] = fgets(fid);
|
< 0.001 | 14 | 33 | tline = tline(1:end-length(lt));
|
< 0.001 | 14 | 34 | if isempty(tline)
|
< 0.001 | 1 | 35 | tline = '';
|
< 0.001 | 14 | 36 | end
|
| | 37 |
|
< 0.001 | 14 | 38 | end
|
Other subfunctions in this file are not included in this listing.