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:
Output from Callback functions ?

Subject: Output from Callback functions ?

From: Talha

Date: 25 May, 2010 08:48:08

Message: 1 of 4

Hi,

I'm a fresh MATLAB user and got stuck with a relatively simple problem.As there is no pointer support(as far as I know), I'm having problems with basic argument passing issues.I decided to post a message over here after no progress for one week.

We are trying to get data from serial port and draw it on a plot.I used the callback functions of serial object.Until here there is no problem at all.But when it comes to get an output from callback or to update an array in the main,I couldn't find a way to do it.

The question is:

How can we output from a callback function? How can we update a value outside of the function within a callback scope?

Any help will be highly appreciated.

Subject: Output from Callback functions ?

From: Sadik

Date: 25 May, 2010 10:41:08

Message: 2 of 4

Hi Talha,

How about keeping your info in the base workspace? You could do:

assignin('base','myVariable',5);

in any of your functions and they all will be updating the same variable, namely myVariable in this example.

Best.

Subject: Output from Callback functions ?

From: SAHIN

Date: 25 May, 2010 12:29:39

Message: 3 of 4

Hi,

I am guessing that, you are using GUIDE and having problem in basic
argument passing.
If that is the case, you can output your structure inside handles.
handles = func_name(hObject,eventdata,handles)
Be aware of the fact that you have to save the handles structure where
you like it by using the below matlab function.
guidata(hObject, handles).

If you like to update a value within a callback scope you can use
nested functions.
Any variable you defined at the outher function will be updated by the
nested functions.
Or try using global variables.

If you explain us, how you use your callbacks, it would be easier to
suggest a solution.

Sahin AKTAS



On May 25, 10:48 am, "Talha " <ta...@talhakoc.com> wrote:
> Hi,
>
> I'm a fresh MATLAB user and got stuck with a relatively simple problem.As there is no pointer support(as far as I know), I'm having problems with basic argument passing issues.I decided to post a message over here after no progress for one week.
>
> We are trying to get data from serial port and draw it on a plot.I used the callback functions of serial object.Until here there is no problem at all.But when it comes to get an output from callback or to update an array in the main,I couldn't find a way to do it.
>
> The question is:
>
> How can we output from a callback function? How can we update a value outside of the function within a callback scope?
>
> Any help will be highly appreciated.

Subject: Output from Callback functions ?

From: Steven Lord

Date: 25 May, 2010 14:22:36

Message: 4 of 4


"Talha " <talha@talhakoc.com> wrote in message
news:htg2s7$j2f$1@fred.mathworks.com...
> Hi,
>
> I'm a fresh MATLAB user and got stuck with a relatively simple problem.As
> there is no pointer support(as far as I know), I'm having problems with
> basic argument passing issues.I decided to post a message over here after
> no progress for one week.
>
> We are trying to get data from serial port and draw it on a plot.I used
> the callback functions of serial object.Until here there is no problem at
> all.But when it comes to get an output from callback or to update an array
> in the main,I couldn't find a way to do it.
>
> The question is:
>
> How can we output from a callback function?

You can't, not directly. Where (in terms of which workspace) would you
expect the output to go?

> How can we update a value outside of the function within a callback scope?

Take a look at these sections in the documentation, depending on whether or
not you're using GUIDE for your GUI.

http://www.mathworks.com/access/helpdesk/help/techdoc/creating_guis/f5-998197.html

http://www.mathworks.com/access/helpdesk/help/techdoc/creating_guis/f13-998197.html

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

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