Using fgetl() to read lines

How can I choose different line to read instead first line, using fgetl() formula?
Thank you.

 采纳的回答

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 个评论

Thak You, I used this function, and it's working freat. It's very usefull that it's save as char.
I have one more question, can I choose two lines to read like second and third in one time, how can I do it?
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

0 个投票

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.

类别

帮助中心File Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by