The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Number of line in a text file
Replies: 12   Last Post: Jan 23, 2013 1:51 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 139
Registered: 3/28/06
Re: Number of line in a text file
Posted: Nov 2, 2006 3:28 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Indeed -- 4.65sec vs former 7.6sec!!!

JWagberg wrote:
> Kirill wrote:
> > while ~feof(fh)
> > ch = fread(fh, chunksize, 'uchar');
> > if isempty(ch)
> > break
> > end

> ...
> > n2 = n2 + sum(ch == char(10));
> Prepend the 'uchar' with an asterisk, '*uchar', and you can read eight
> times as much with each chunk and the (ch == char(10)) will also speed
> up by a factor five.
> /jewa

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.