Path: news.mathworks.com!not-for-mail
From: "Duane Hanselman" <masteringmatlab@yahoo.spam.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: eval, feval, global
Date: Thu, 27 Mar 2008 10:07:22 +0000 (UTC)
Organization: University of Maine
Lines: 26
Message-ID: <fsfrkq$ev4$1@fred.mathworks.com>
References: <fsebf0$43u$1@fred.mathworks.com> <fsf3ss$e2e$1@fred.mathworks.com>
Reply-To: "Duane Hanselman" <masteringmatlab@yahoo.spam.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1206612442 15332 172.30.248.38 (27 Mar 2008 10:07:22 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 27 Mar 2008 10:07:22 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 92533
Xref: news.mathworks.com comp.soft-sys.matlab:459420


"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