How can I skip lines when reading from a text file

조회 수: 21 (최근 30일)
Ahmed
Ahmed 2013년 7월 19일
댓글: Berenice Cervantes 2020년 5월 6일
Hello All,
I have a text file with the extension .rep
I need to skip the first 36 lines and then start reading numeric data.
How can I do this?
Thanks alot,
Ahmed

채택된 답변

David Sanchez
David Sanchez 2013년 7월 19일
You could try the built-in function fgets:
fid = fopen('my_file.m');
% read the first 36 lines and do nothing to them
for k=1:36
tline = fgets(fid);
end
% next reading will be on 37th line.
% display form 37th line forward:
while ischar(tline)
disp(tline)
tline = fgets(fid);
end
fclose(fid)
For more details, type:
help fgets
doc fgets

추가 답변 (1개)

YUMIN HO
YUMIN HO 2019년 6월 14일
thank you for the answer

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by