| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
tline = fgetl(fileID)
tline = fgetl(fileID) returns the next line of the specified file, removing the newline characters. fileID is an integer file identifier obtained from fopen. tline is a text string unless the line contains only the end-of-file marker. In this case, tline is the numeric value -1.
fgetl reads characters using the encoding scheme associated with the file. To specify the encoding scheme, use fopen.
Read and display the file fgetl.m one line at a time:
fid = fopen('fgetl.m');
tline = fgetl(fid);
while ischar(tline)
disp(tline)
tline = fgetl(fid);
end
fclose(fid);Compare these results to the fgets example, which replaces the calls to fgetl with fgets.
fclose | ferror | fgets | fopen | fprintf | fread | fscanf | fwrite
![]() | fftw | fgetl (serial) | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |