Path: news.mathworks.com!not-for-mail
From: "Kenneth Eaton" <Kenneth.dot.Eaton@cchmc.dot.org>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Why are cell arrays so much faster?
Date: Fri, 11 Jul 2008 20:32:05 +0000 (UTC)
Organization: Cincinnati Children's Hospital Research Center
Lines: 29
Message-ID: <g58g05$ie3$1@fred.mathworks.com>
References: <g58e4n$13t$1@fred.mathworks.com>
Reply-To: "Kenneth Eaton" <Kenneth.dot.Eaton@cchmc.dot.org>
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 1215808325 18883 172.30.248.37 (11 Jul 2008 20:32:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 11 Jul 2008 20:32:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1165924
Xref: news.mathworks.com comp.soft-sys.matlab:478932



"David Doria" <daviddoria@gmail.com> wrote in message 
<g58e4n$13t$1@fred.mathworks.com>...
> Below is my experiment - I actually expected the opposite!
> 
> >> tic; CubeA(1:300, 1:360, 1) = repmat(1000,300,360); toc
> Elapsed time is 0.003197 seconds.
> >> tic; CubeB{1} = repmat(1000,300,360); toc
> Elapsed time is 0.000964 seconds.
> 
> Why is this the case?  
> 
> Thanks,
> 
> Dave

I couldn't reproduce those results, so I couldn't tell you 
what's going on. I did, however, make an interesting 
discovery:

>> tic; a=repmat(1000,300,360); toc;
Elapsed time is 0.003951 seconds.
>> tic; b=1000.*ones(300,360); toc;
Elapsed time is 0.005800 seconds.

For some reason, I always thought of repmat as being slower 
than matrix operations. Maybe I'll start using it more now 
=).

Ken