Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Script will take far too long..
Date: Wed, 22 Jul 2009 00:24:01 +0000 (UTC)
Organization: Universit&#228;t Heidelberg
Lines: 29
Message-ID: <h45m71$k6s$1@fred.mathworks.com>
References: <h454s2$k0u$1@fred.mathworks.com> <4fe65105-648f-4e77-9dd4-6a52da136c5f@t13g2000yqt.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1248222241 20700 172.30.248.37 (22 Jul 2009 00:24:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 22 Jul 2009 00:24:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869888
Xref: news.mathworks.com comp.soft-sys.matlab:557363


Dear Rune Allnor!

> There is something wrong. A 1GB computer should have no problems
> whatsoever with handling lines of 1.5 MB.

Waiting 40 min for regexprep is not a "problem", but just slow.
Matlab 6.5 takes 10 min for replacing 125.000 'A_A' with '1' in a 1.5MB string on my 1500MHz PentiumM -- without file access!

> Most likely, the file was generated by a different type of
> computer than your - presumably - PC. If so, the lines are
> ended by different characters than FGETS or FGETL look for.

FGETL calls FGETS, and the later can handle all PC/MacOS9/Unix linebreaks without problems. Even FOPEN(RB) or (RT) does not matter, because FGETL cuts off the line break (of any style), FGETS had found.
Therefore the text file do not need a conversion.

Example:
fid = fopen('test.txt', 'wb');
fwrite(fid, ['Line1', 10, 'Line2', 13, 10, 'Line3', 13, 'END'], 'uchar');
fclose(fid);
fid = fopen(test.txt', 'rb')
fgetl(fid), fgetl(fid), fgetl(fid)
fclose(fid);
fid = fopen(test.txt', 'rt')
fgetl(fid), fgetl(fid), fgetl(fid)
fclose(fid);

So REGEXPREP -> STRREP or the nice perl trick should give enough speed.

Good night, Jan