Thread Subject: basic question re: workspace variables and functions

Subject: basic question re: workspace variables and functions

From: Bryan

Date: 20 Feb, 2008 18:28:01

Message: 1 of 3

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

Subject: basic question re: workspace variables and functions

From: Ilya Rozenfeld

Date: 20 Feb, 2008 18:52:02

Message: 2 of 3

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

Subject: basic question re: workspace variables and functions

From: Bryan

Date: 20 Feb, 2008 19:46:02

Message: 3 of 3

"Ilya Rozenfeld" <rozeni.nospam@alum.rpi.edu> wrote in
message <fphssi$nhb$1@fred.mathworks.com>...
> Try to use "evalin" e.g.
>
>
> datVars = evalin('base', 'who(''data*'')');

uggh, yes, that is the one i was looking for. thanks so much!!

bryan

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
thanks Bryan 20 Feb, 2008 14:50:12
solved Bryan 20 Feb, 2008 14:50:12
assignin Bryan 20 Feb, 2008 13:30:23
function Bryan 20 Feb, 2008 13:30:23
workspace varia... Bryan 20 Feb, 2008 13:30:23
rssFeed for this Thread

Contact us at files@mathworks.com