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:
How to share data between callback and external function

Subject: How to share data between callback and external function

From: Arthur

Date: 17 Apr, 2008 10:15:03

Message: 1 of 3

This is a callback routine (for an uimenu component) I wrote
using GUIDE:

  function new_pt_Callback(hObject, eventdata, handles)
  ...
  ...
  display_coord(hObject,handles);
  handles

The function display_coord has to modify the handles:

  function display_coord(hObject,handles)
  ...
  handles.ptr = ...;
  handles.coordStr = ...;
  ...
  guidata(hObject,handles);

Before leaving display_coord, I used guidata to update the
handles. But as I checked handles (in new_pt_Callback), the
fields 'ptr' and 'coordStr' were not added. It's still the
same as before I called display_coord.

How do I modify handles from external function such as
display_coord?

Thanks!

Arthur

Subject: How to share data between callback and external function

From: Vihang Patil

Date: 17 Apr, 2008 12:47:24

Message: 2 of 3

"Arthur " <aniswar@i2r.a-star.edu.sg> wrote in message
<fu77v7$i3m$1@fred.mathworks.com>...
> This is a callback routine (for an uimenu component) I
wrote
> using GUIDE:
>
> function new_pt_Callback(hObject, eventdata, handles)
> ...
> ...
> display_coord(hObject,handles);
> handles
>
> The function display_coord has to modify the handles:
>
> function display_coord(hObject,handles)
> ...
> handles.ptr = ...;
> handles.coordStr = ...;
> ...
> guidata(hObject,handles);
>
> Before leaving display_coord, I used guidata to update
the
> handles. But as I checked handles (in new_pt_Callback),
the
> fields 'ptr' and 'coordStr' were not added. It's still
the
> same as before I called display_coord.
>
> How do I modify handles from external function such as
> display_coord?
>
> Thanks!
>
> Arthur
>

Hello Arthur
This was a similar problem ,that I had faced too recently
while designing my gui and the thread of the same is
attached here. The solution to it is posted by FRENCH CARO
in the same thread.
http://www.mathworks.com/matlabcentral/newsreader/view_thre
ad/167401#426899

HTH
Vihang

Subject: How to share data between callback and external function

From: Arthur

Date: 18 Apr, 2008 01:04:02

Message: 3 of 3

>
> Hello Arthur
> This was a similar problem ,that I had faced too recently
> while designing my gui and the thread of the same is
> attached here. The solution to it is posted by FRENCH CARO
> in the same thread.
> http://www.mathworks.com/matlabcentral/newsreader/view_thre
> ad/167401#426899
>
> HTH
> Vihang

Thanks, Vihang! That solves the problem!

Arthur

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