Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: Read variables from Workspace

Subject: Read variables from Workspace

From: Rami AbouSleiman

Date: 18 Apr, 2008 18:13:01

Message: 1 of 7

HELP PLEASE
Is it possible to have a function that reads specific values
from the workspace, even though these values are always
changing?
And when these values change the function updates its values
also
Thank you

Subject: Re: Read variables from Workspace

From: plim

Date: 18 Apr, 2008 18:54:51

Message: 2 of 7

what do you mean with workspace?

Subject: Re: Read variables from Workspace

From: Rami AbouSleiman

Date: 18 Apr, 2008 19:14:02

Message: 3 of 7

plim <manuela.cotrim@gmail.com> wrote in message
<1e392b5f-2ba0-485f-b913-6d2b2fb6d2f3@k37g2000hsf.googlegroups.com>...
> what do you mean with workspace?


Are you serious?
check your matlab main window, its a small box that has all
your variables in your current directory.
for example you might declare x=5; in your code you will see
it as x=5 in your workspace and if you type x in your
command window you will get 5
i dont know why i am telling you this if you dont know
workspace how would you help me
 

Subject: Read variables from Workspace

From: Bruno Luong

Date: 18 Apr, 2008 19:36:02

Message: 4 of 7

"Rami AbouSleiman" <rdabousl@oakland.edu> wrote in message
<fuaobd$hbu$1@fred.mathworks.com>...
> HELP PLEASE
> Is it possible to have a function that reads specific values
> from the workspace, even though these values are always
> changing?
> And when these values change the function updates its values
> also

You could declare the variable as "global".

Anyway, global variable and accessing/sharing variables
between different workspaces is the last thing I would
recommend to do.

Out of curious, what changes the variable that you want to
monitor? An acquisition board? A timer?

Bruno

Subject: Read variables from Workspace

From: Rami AbouSleiman

Date: 18 Apr, 2008 20:28:02

Message: 5 of 7

"Bruno Luong" <b.luong@fogale.fr> wrote in message <fuat72
$ll4$1@fred.mathworks.com>...
> "Rami AbouSleiman" <rdabousl@oakland.edu> wrote in message
> <fuaobd$hbu$1@fred.mathworks.com>...
> > HELP PLEASE
> > Is it possible to have a function that reads specific
values
> > from the workspace, even though these values are always
> > changing?
> > And when these values change the function updates its
values
> > also
>
> You could declare the variable as "global".
>
> Anyway, global variable and accessing/sharing variables
> between different workspaces is the last thing I would
> recommend to do.
>
> Out of curious, what changes the variable that you want to
> monitor? An acquisition board? A timer?
>
> Bruno


Thanks Bruno but i declared already as global thats why the
workspcae is changing but not the function.
Its the mouse movement on a figure (variables changing)

Subject: Read variables from Workspace

From: Bruno Luong

Date: 18 Apr, 2008 21:29:02

Message: 6 of 7

"Rami AbouSleiman" <rdabousl@oakland.edu> wrote in message
<fub08i$nek$1@fred.mathworks.com>...
 
> Thanks Bruno but i declared already as global thats why the
> workspcae is changing but not the function.

I'm not sure I understand:

when a variable is declared as global, it stores in a space
that is common for all workspaces (WS).

Each function has they own WS. In order to access to this
variable, the variable should be declared as global in the
function, otherwise the homonym variable (same name) is
created in a local workspace.

You could also use "evalin" and "assignin" for manipulation
variables at different WS.

For mouse position, check out also this:
 get(0, 'PointerLocation')

Bruno


Subject: Re: Read variables from Workspace

From: Ralph Schleicher

Date: 19 Apr, 2008 07:40:46

Message: 7 of 7

"Rami AbouSleiman" <rdabousl@oakland.edu> writes:

> Is it possible to have a function that reads specific values
> from the workspace, even though these values are always
> changing?
> And when these values change the function updates its values
> also

You can use 'evalin' for reading from and 'assignin' for writing to
the base workspace. For example,

function foo
  x = evalin('base', 'x');

--
Ralph Schleicher, Freelance Engineer http://ralph-schleicher.de

Development * Consulting * Training
Mathematical Modeling and Simulation
Software Tools

Tags for this Thread

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.

rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics