Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to rename a workspace variable in a loop?
Date: Thu, 19 Jul 2007 21:48:38 +0000 (UTC)
Organization: The MathWorks Inc
Lines: 14
Message-ID: <f7om7m$dvb$1@fred.mathworks.com>
References: <f7olca$1mj$1@fred.mathworks.com>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: webapp-01-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1184881718 14315 172.30.248.36 (19 Jul 2007 21:48:38 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 19 Jul 2007 21:48:38 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 493281
Xref: news.mathworks.com comp.soft-sys.matlab:419999


"Nizar " <pakoeli@hotmail.com> wrote in message <f7olca$1mj$1@fred.mathworks.com>...
> Hi,
> 
> I was wondering how you could rename a workspace variable in a loop? What I have is a loop that generates results which are stored in a matrix. the problem is that in the 2nd loop the matrix is overwritten. I also cannot add both matrices, because they are not of the same size. 
> 
> Therefore i wanted to know how to rename the workspace variable for each loop generation. for example when using a "for" loop with i=1:1:5 how can I name the matrix M for each loop with a increment, thus M1, M2, M3, etc... so that I can analyze all the data and not that of only the last loop.

Don't.  See question 4.6 in the newsgroup FAQ for some of the reasons you shouldn't do this and alternatives to doing this.

http://matlabwiki.mathworks.com/MATLAB_FAQ

-- 
Steve Lord
slord@mathworks.com