Thread Subject: tips needed to make code run faster

Subject: tips needed to make code run faster

From: nukeymusic

Date: 20 Dec, 2011 10:52:09

Message: 1 of 2

Is it possible to make the following code run faster?

clear
%example format of testfile which has thousands of these lines
%Dec-01-13:18:59 24.8 +1.54415760E-01 7.387060E-06 2.579755E+00
%Dec-01-13:19:26 24.8 +1.54396330E-01 7.389665E-06 2.580398E+00
%Dec-01-13:19:53 24.8 +1.54362790E-01 7.391425E-06 2.580347E+00
fmt = "%s %f %f %f %f";
[A, B, C, D, E] = textread("testfile", fmt);
y=[(datenum(cell2mat(A),'mmm-dd-HH:MM:SS')-datenum(cell2mat(A(1)),'mmm-
dd-HH:MM:SS'))*24*60*60 B C D E];
save('outputfile','y');

thanks in advance
nukey

Subject: tips needed to make code run faster

From: Rune Allnor

Date: 20 Dec, 2011 11:32:40

Message: 2 of 2

On 20 Des, 11:52, nukeymusic <nukeymu...@gmail.com> wrote:
> Is it possible to make the following code run faster?
>
> clear
> %example format of testfile which has thousands of these lines
> %Dec-01-13:18:59 24.8 +1.54415760E-01 7.387060E-06 2.579755E+00
> %Dec-01-13:19:26 24.8 +1.54396330E-01 7.389665E-06 2.580398E+00
> %Dec-01-13:19:53 24.8 +1.54362790E-01 7.391425E-06 2.580347E+00
> fmt = "%s %f %f %f %f";
> [A, B, C, D, E] = textread("testfile", fmt);
> y=[(datenum(cell2mat(A),'mmm-dd-HH:MM:SS')-datenum(cell2mat(A(1)),'mmm-
> dd-HH:MM:SS'))*24*60*60 B C D E];
> save('outputfile','y');
>
> thanks in advance
> nukey

Processing text files take time. Expect 5-10
minutes per GByte.

Apart from that, with the skill level indicated
by your question about writing files a couple of
days ago, you might be better off leaving your
computer to process your files overnight. Learning
the skills necessary to do this will take you
some time. That effort would only be justified
if you want to learn programming, or if you need
to do this kind of processing under time pressure
on a daily basis.

Rune

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com