Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Read data from different workspace

Subject: Read data from different workspace

From: wapo

Date: 31 Jul, 2009 08:49:48

Message: 1 of 3

Hi all,

I have a rather theoretical question. I have two workspaces (due to
GUI) that I am building. In order to share data between different
objects of the GUI I currently write some data in the base workspace
(with assignin) and then read that data from another objects workspace
(evalin). I was wondering if its possible to use the data from the
base workspace without making a local copy first. For example I have a
matrix in base. Can I call a plot from a different workspace using the
data for the matrix from the base.

thanks in advance

Apostolos

Subject: Read data from different workspace

From: us

Date: 31 Jul, 2009 09:07:02

Message: 2 of 3

wapo <apostolos1975@gmail.com> wrote in message <c6e68a82-b843-47bf-ad37-2ed3dcc5f731@r38g2000yqn.googlegroups.com>...
> Hi all,
>
> I have a rather theoretical question. I have two workspaces (due to
> GUI) that I am building. In order to share data between different
> objects of the GUI I currently write some data in the base workspace
> (with assignin) and then read that data from another objects workspace
> (evalin). I was wondering if its possible to use the data from the
> base workspace without making a local copy first. For example I have a
> matrix in base. Can I call a plot from a different workspace using the
> data for the matrix from the base.
>
> thanks in advance

> Apostolos

you should re-think your approach and consider using one of the data containers, eg,

     help guidata;
     help getappdata; % <- and siblings

us

Subject: Read data from different workspace

From: Thomas Clark

Date: 31 Jul, 2009 09:25:04

Message: 3 of 3

Less elegant than urs' solution, but quite easy to do, you can use global variables to share between workspaces. I sometimes do that to provide input/output to/from a GUI.

% In some workspace
global MYDATA
MYDATA = 10;

% In a GUI function, say the openingFcn
function [blah] = openingFcn(blah)
% Declare that you want access to that global variable
global MYDATA
% Use the global variable. It's wise to make a local copy of it so that other programs can't mess with your GUI
handles.local_mydata = MYDATA;


More generally (not really for GUIs but useful for subfunctions) You can use the concept of nested functions to share workspaces between functions.



wapo <apostolos1975@gmail.com> wrote in message <c6e68a82-b843-47bf-ad37-2ed3dcc5f731@r38g2000yqn.googlegroups.com>...
> Hi all,
>
> I have a rather theoretical question. I have two workspaces (due to
> GUI) that I am building. In order to share data between different
> objects of the GUI I currently write some data in the base workspace
> (with assignin) and then read that data from another objects workspace
> (evalin). I was wondering if its possible to use the data from the
> base workspace without making a local copy first. For example I have a
> matrix in base. Can I call a plot from a different workspace using the
> data for the matrix from the base.
>
> thanks in advance
>
> Apostolos

Tags for this Thread

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.

Contact us