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:
i also need helps with sharing data between callbacks

Subject: i also need helps with sharing data between callbacks

From: Jeong Yeol

Date: 2 Dec, 2010 02:12:05

Message: 1 of 4

hellow guys~
i read some comments about sharing data between callbacks.
http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.3F
i've tried to solve it but i couldn't understand the explanation exactly.

--------main m file--------------------------------------------------
function Statistical_analysis_data_OpeningFcn(hObject, eventdata, handles, varargin)
:
:
push_btn4 = uicontrol(gcf,...
                 'Style', 'pushbutton',...
                'Position',[315 62 142.5 33],...
               'String', 'pro',...
              'CallBack','Probability_distribution');
             
push_btn5 = uicontrol(gcf,...
                 'Style', 'pushbutton',...
                 'Position',[315 21 142.5 33],...
                 'String', 'out',...
                 'CallBack','Outlier_analysis');
:
:
end
:
:
function pushbutton2_Callback(hObject, eventdata, handles)

[file,path] = uigetfile('*.txt','Save data As','c:\test\input\');
user_input_data = strcat(path,file);
A= importdata(user_input_data);
:
:
-----------------sub m file ('Probability_distribution')------------

------------------------------------------------------------------------
i want to send some variables from main m file as 'A'and etc to sub m files.
or send some variables from sub m file to main m file for saving datas on main m file.
the sub m file ('Probability_distribution') will be opened by pushbutton coded in
'Statistical_analysis_data_OpeningFcn'

so anyone give me a example code in detail ? plz~

Subject: i also need helps with sharing data between callbacks

From: Paulo

Date: 2 Dec, 2010 02:37:05

Message: 2 of 4

There are several ways to do that, one is to pass the data using:

% use this to save data
setappdata(0,'SomeData',variable)

% use this to get data
variable = getappdata(0,'SomeData')

% to remove what you saved
rmappdata(0,'SomeData')

You can use diferent names for your saved data instead of SomeData

good luck

Subject: i also need helps with sharing data between callbacks

From: ImageAnalyst

Date: 2 Dec, 2010 03:18:28

Message: 3 of 4

Watch these video tutorials:

http://www.mathworks.com/matlabcentral/fileexchange/8616

http://blogs.mathworks.com/pick/2008/04/17/advanced-matlab-handles-and-other-inputs-to-guide-callbacks/

Subject: i also need helps with sharing data between callbacks

From: ImageAnalyst

Date: 2 Dec, 2010 03:50:00

Message: 4 of 4

I tried to clarify the FAQ on that topic. See if it makes more sense
now.

Tags for this Thread

No tags are associated with 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