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:
returning structure of data from a callback funtion

Subject: returning structure of data from a callback funtion

From: Jose

Date: 4 Aug, 2010 15:10:08

Message: 1 of 3

Hello everyone,

how can I return my structure of data once is updating from a callback function to the main program?

%This s my structure of data called st:

st:

hfigure: {[1] [] [3] [] []}
           hz: [0.1000 0.1000 0.1000 0.1000 0.1000]
       deltaz: [1 1 1 1 1]
         icxx: [0 0 0 0 0]
        isxxy: [0 0 0 0 0]
     
%This is the callback function "stoprecording" to update my structure of data st:

hseek=uicontrol('parent',st.hfigure{e},'String', 'seek',...
       'Position', [10,10,60,20]);
    set(hseek,'Callback',@(src,event)stoprecording(src,event,st));

function stoprecording(src,~,st)

val=get(src,'parent')

st.icxx(val)=2;

st.hz(val)=2;

 
 return


Thanks in advance.

Subject: returning structure of data from a callback funtion

From: Walter Roberson

Date: 4 Aug, 2010 15:44:07

Message: 2 of 3

Jose wrote:

> how can I return my structure of data once is updating from a callback
> function to the main program?

You cannot return anything from a callback, so you must use different
approaches, such as nested variables, setappdata() / getappdata(),
setting the Userdata property of a graphics object, or using global
variables.

Subject: returning structure of data from a callback funtion

From: Jose

Date: 4 Aug, 2010 17:20:05

Message: 3 of 3

Walter Roberson <roberson@hushmail.com> wrote in message <bVf6o.53352$dx7.45937@newsfe21.iad>...
> Jose wrote:
>
> > how can I return my structure of data once is updating from a callback
> > function to the main program?
>
> You cannot return anything from a callback, so you must use different
> approaches, such as nested variables, setappdata() / getappdata(),
> setting the Userdata property of a graphics object, or using global
> variables.

Thank you Walter.

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