[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: just for the sake of curiosity ...
From: |
Dr.-Ing. Dieter Jurzitza |
Subject: |
Re: just for the sake of curiosity ... |
Date: |
Sat, 18 Jun 2016 15:26:03 +0200 |
User-agent: |
KMail/4.14.10 (Linux/4.1.21-15.2-default; KDE/4.14.18; x86_64; ; ) |
Dear Dimitri,
dear listmembers,
I tested again and I was astonished:
getting my two vectors like
tic
[X,Y]=textread("Kennlinie.dat", "%f %f");
toc
is the most "obvious" solution. This takes 5.2ms on my computer (a tiny file,
only 38 values in total to read).
doing a
tic
infile=fopen ("Kennlinie.dat", "r");
A=fscanf(infile, "%f %f", [2 Inf]);
A=A';
X=A(:,1);
Y=A(:,2);
fclose (infile);
toc
does exactly the same, however, it takes only about 225µs in total - or this
is roughly 25 times faster that textread();
Not a concern for me as 5ms are meaningless in comparison to 0.5s what is the
total runtime of my script, just as 225µs are, however, who has larger infiles
to read might consider this signifikant.
Just to let you know - and thank you Dimitri, the only modification of your
suggestion is the line A=A'; otherwise X and Y contain only one value.
Take care, thanks again,
Dieter Jurzitza
Am Samstag, 18. Juni 2016, 05:41:19 schrieb Dmitri A. Sergatskov:
> On Sat, Jun 18, 2016 at 5:36 AM, Dmitri A. Sergatskov <
>
> address@hidden> wrote:
> > Try
> > z = fscanf(infile, "%f %f");
>
> This should be
>
> z = fscanf(infile, "%f %f", [2, inf])
>
> > x=z(:,1), y = z(:,2);
>
> Dmitri.
--
-----------------------------------------------------------
|
\
/\_/\ |
| ~x~ |/-----\ /
\ /- \_/
^^__ _ / _ ____ /
<°°__ \- \_/ | |/ | |
|| || _| _| _| _|
if you really want to see the pictures above - use some font
with constant spacing like courier! :-)
-----------------------------------------------------------