Path: news.mathworks.com!not-for-mail
From: "John D'Errico" <woodchips@rochester.rr.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: eval, feval, global
Date: Thu, 27 Mar 2008 10:57:01 +0000 (UTC)
Organization: John D'Errico (1-3LEW5R)
Lines: 41
Message-ID: <fsfuht$e44$1@fred.mathworks.com>
References: <fsebf0$43u$1@fred.mathworks.com> <fsf3ss$e2e$1@fred.mathworks.com> <fsfrld$fep$1@fred.mathworks.com>
Reply-To: "John D'Errico" <woodchips@rochester.rr.com>
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 1206615421 14468 172.30.248.37 (27 Mar 2008 10:57:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 27 Mar 2008 10:57:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869215
Xref: news.mathworks.com comp.soft-sys.matlab:459440


"Duane Hanselman" <masteringmatlab@yahoo.spam.com> wrote in message 
<fsfrld$fep$1@fred.mathworks.com>...
> "Yuri Geshelin" <geshelin@hotmail.com> wrote in message >
> Suppose we have 2 arrays of equal length:
> > 
> > a = [15 23 35 43];
> > b = [ 2 11  8  3];
> > 
> > and we need an algorithm, which constructs output array c 
> > as follows:
> > 
> > c = [15 15 <23 repeated 11 times> <35 repeated 8 times> 43 
> > 43 43]
> > 
> > Here is a simple function construct_array1, which 
> > accomplishes this task.
> 
> Try the function MMREPEAT from the File Exchange. It does
> exactly this and does not use EVAL. Avoid EVAL!
> 
> Compare its speed to your two functions.
> 
> http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?
objectId=1024&objectType=file
> 
> 
> Duane Hanselman

It seems ironic that Duane's response about
mmrepeat got repeated by the website. 8-)

The point I'll make is that Yuri's problem,
which he solves using eval in a rather
inelegant way, is far more efficiently
solved using mmrepeat.

Eval is very rarely necessary. (As opposed
to feval, which I'll agree does have some
uses.)

John