Path: news.mathworks.com!not-for-mail
From: "Rick Rosson" <rrosson@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to rename a workspace variable in a loop?
Date: Thu, 19 Jul 2007 17:41:39 -0400
Organization: The MathWorks, Inc.
Lines: 57
Message-ID: <f7olql$88k$1@fred.mathworks.com>
References: <f7olca$1mj$1@fred.mathworks.com> <f7oloa$75a$1@fred.mathworks.com>
Reply-To: "Rick Rosson" <rrosson@mathworks.com>
NNTP-Posting-Host: rossonr.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1184881301 8468 144.212.206.185 (19 Jul 2007 21:41:41 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 19 Jul 2007 21:41:41 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138
Xref: news.mathworks.com comp.soft-sys.matlab:419998


Sorry, make that:

    eval([ 'M' num2str(i) ' = M;' ]);




"Rick Rosson" <rrosson@mathworks.com> wrote in message 
news:f7oloa$75a$1@fred.mathworks.com...
> Use the EVAL function
>
> Type:
>
>   doc eval
>
> at the command prompt.
>
>
> For example:
>
>  for i = 1:5
>
>     ...
>     ...
>
>     eval([ 'M' num2str(k) ' = M;' ]);
>
>     ...
>     ...
>
>  end
>
>
>
>
> "Nizar " <pakoeli@hotmail.com> wrote in message 
> news: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.
>>
>> any suggestions are appreciated.
>>
>> thank you
>
>