Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to save time loading data from file
Date: Mon, 4 Aug 2008 10:15:14 -0400
Organization: The MathWorks, Inc.
Lines: 30
Message-ID: <g772ti$6rf$1@fred.mathworks.com>
References: <g75abr$40d$1@fred.mathworks.com>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: lords.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1217859314 7023 144.212.105.187 (4 Aug 2008 14:15:14 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 4 Aug 2008 14:15:14 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Original
Xref: news.mathworks.com comp.soft-sys.matlab:483507




"ggk " <ggkmath@comcast.net> wrote in message 
news:g75abr$40d$1@fred.mathworks.com...
> Hi,
>
> I've run a profile on my code and found that 90% of the
> time running my .m file is consumed by one line of code:
>
> x = load('data.txt');
>
> I'm using 1GB RAM (Windows XP 3GHz Pentium4). The file
> contains ascii data -- one data point (double precision)
> per row, and many rows.
>
> Can anyone share their insight how to speed this up?

LOAD needs to "figure out" how to read in your data (i.e. it needs to 
determine how the file is formatted) and that takes some time.  If you know 
the format of your data file (for instance, the fact that each row contains 
exactly one double-precision number followed by a newline), make use of that 
information with some of the other file I/O functions (like DLMREAD, 
CSVREAD, TEXTSCAN, or even the low-level FOPEN/FSCANF/FCLOSE functions.)  If 
you use a more "focused" reader rather than the general LOAD, you may see 
some improvement.

-- 
Steve Lord
slord@mathworks.com