Path: news.mathworks.com!not-for-mail
From: "Ilya Rozenfeld" <rozeni.nospam@alum.rpi.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Re: basic question re: workspace variables and functions
Date: Wed, 20 Feb 2008 18:52:02 +0000 (UTC)
Organization: Citizens Bank
Lines: 42
Message-ID: <fphssi$nhb$1@fred.mathworks.com>
References: <fphrfh$4l8$1@fred.mathworks.com>
Reply-To: "Ilya Rozenfeld" <rozeni.nospam@alum.rpi.edu>
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 1203533522 24107 172.30.248.35 (20 Feb 2008 18:52:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 20 Feb 2008 18:52:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1195850
Xref: news.mathworks.com comp.soft-sys.matlab:452716



Try to use "evalin"  e.g.


datVars = evalin('base', 'who(''data*'')');


"Bryan " <cssmwbs@gmail.com> wrote in message <fphrfh$4l8
$1@fred.mathworks.com>...
> hi all,
> 
> how do i make a function aware of the variables in my 
matlab
> desktop workspace?  i am trying to figure out how to get 
a
> function to do something with a set of workspace 
variables,
> without having to explicitly pass each variable as an 
input
> argument to the function.  the reason for this is, for
> example, i may have a lot of 'data*' variables (where * 
is
> some further identifier, like a datenum or something), 
and i
> want my function to get all the 'data*' variables, and do
> something with them.  i was thinking to use assignin, 
but i
> cannot figure out how to do so, given that if i try and 
find
> the workspace variables in my function using something 
like
> 
> datVars = who('data*');
> 
> the function returns datVars as an empty array.  i am 
quite
> sure this is something basic, but i have looked around 
and
> am still confused.
> 
> regards,
> bryan