Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: EVAL within EVAL
Date: Mon, 2 Nov 2009 20:32:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 39
Message-ID: <hcnfk3$6f6$1@fred.mathworks.com>
References: <hclda3$slq$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257193923 6630 172.30.248.37 (2 Nov 2009 20:32:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 2 Nov 2009 20:32:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2073414
Xref: news.mathworks.com comp.soft-sys.matlab:581907


"Ariel Krieger" <srigi001@gmail.com> wrote in message <hclda3$slq$1@fred.mathworks.com>...
> Hello all,
> 
> I'm trying to do something very basic with EVAL but not getting there.
> 
> So I have a set of vectors x1...xn and in a for loop I want to perform some arithmatic on them.
> 
> I use EVAL to create them automatically with the proper name and all:
> 
> for i = 1:10
> eval(['x' num2str(i) ' = ones(1,100)']);
> end
> 
> that creates vectors x1, x2, ..., x10 which are 1 X 100 row vectors containing ones.
> 
> Now the problem is I want to do something like this (just for example):
> 
> x1 = x1 * 3;
> x2 = x2 * 3;
> .
> .
> .
> 
> can I use eval within eval? I'm trying something like:
> 
> for i = 1: 10
> eval(['x' num2str(i) ' = eval(['x' num2str(i) ' ']) * 3']);
> end
> 
> but obviously that doesn't fly, any suggestions?
> 
> Thanks

Try using 

MatrixNames = whos('N*')
for ii=1:length(MatrixNames)
eval([MatrixNames(ii).name '=' MatrixNames(ii).name '*3'])
end