Path: news.mathworks.com!not-for-mail
From: "Sadik " <sadik.hava@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: num2str in loop
Date: Tue, 20 Jan 2009 00:30:06 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 21
Message-ID: <gl35ue$cp2$1@fred.mathworks.com>
References: <gl35f9$arm$1@fred.mathworks.com>
Reply-To: "Sadik " <sadik.hava@gmail.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1232411406 13090 172.30.248.35 (20 Jan 2009 00:30:06 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 20 Jan 2009 00:30:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1666517
Xref: news.mathworks.com comp.soft-sys.matlab:512588

"simon ott" <simon_ott@yahoo.com> wrote in message <gl35f9$arm$1@fred.mathworks.com>...
> hello
> I want to assign the name of a variable based on loop iteration. 
> 
> b = [3 4 ]
> 
> Iteration = 1: 2
> 
> ['abc' num2str(Iteration)] =   b(i) 
> 
> End
> 
> 
> But it does not work
> 
> Any hint ?

Yes, that wouldn't work. Have you tried using eval as follows?

eval(['abc' num2str(Iteration) '=   b(i);'])