Using fgetl() to read lines

조회 수: 8 (최근 30일)
ZK
ZK 2013년 1월 10일
How can I choose different line to read instead first line, using fgetl() formula?
Thank you.

채택된 답변

Amith Kamath
Amith Kamath 2013년 1월 10일
http://www.mathworks.com/matlabcentral/newsreader/view_thread/297814 may be of some help. Unless you are constrained to using fgetl() for some reason,
C = textscan(fid, '%s','delimiter', '\n');
% Setup the line number in LineNum,
RelevantLine=C{1}{Linenum};
should do the trick.
  댓글 수: 3
Amith Kamath
Amith Kamath 2013년 1월 11일
I agree with Walter that this stores the entire file into the cell array, and isn't technically skipping lines. You could possibly choose more lines by using strcat on C{1}{LineNum1} and C{1}{LineNum2}.
ZK
ZK 2013년 1월 11일
편집: ZK 2013년 1월 11일
Thank You I will remember that.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2013년 1월 10일
There is no method at the operating system level to position by line. The operating system itself uses fgetl() (or fgets()) to move forward by lines. MATLAB does not provide any "wrapper" over fgetl() to support skipping lines.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by