Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: genvarname doesn't work
Date: Fri, 10 Jul 2009 17:20:18 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 13
Message-ID: <h37t8i$6kh$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1247246418 6801 172.30.248.38 (10 Jul 2009 17:20:18 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 10 Jul 2009 17:20:18 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1646679
Xref: news.mathworks.com comp.soft-sys.matlab:554520


I have R2007b, and copied and pasted this code from the matlab documentation:

for k = 1:5
   t = clock;
   pause(uint8(rand * 10));
   v = genvarname('time_elapsed', who);
   eval([v ' = etime(clock,t)'])
   end

and it doesn't work because genvarname('aa') gives [0 0]
ie, for every character in the string, a new element is created in the output vector.

The code above doesn't even run without an error message.  Was this function modified in a new version of matlab or something ??