The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Cannot find Callback function within m-file
Replies: 2   Last Post: Apr 10, 2013 5:02 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
kees de kapper

Posts: 86
Registered: 12/7/04
Cannot find Callback function within m-file
Posted: Mar 20, 2013 9:32 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi All,

new question. Hope you could help me with this one:

I'm trying to make my MenuItems dynamically and add Callback functions to it:

> FigName ='Hello';
> set(handles.MenuItem, 'Callback', {eval(['@(hObject, handles) ,FigName,'_CallBack','(hObject,eventdata,guidata(hObject))'])});

And I have created a functionlike this:
> function handles = Hello_CallBack(hObject, eventdata, handles)
> % some code

If I run the code, and select the MenuItem then I will get the following error:
Undefined function 'Hello_CallBack' for input arguments of type 'struct'.
Error in gui_mainfcn (line 94)
[varargout{1:nargout}] = feval(varargin{:});

If I change the callback definition to:
> set(handles.MenuItem, 'Callback', {eval(['@',FigName,'_CallBack'])});

then I will get an error like this:
Undefined function 'Hello_CallBack' for input arguments of type 'double'.
Error while evaluating uimenu Callback

I've tried "which" to see whether the function was available, but indeed it wasn't listed there.

Why is the function not visible/available?

Many thanks!

Kind regards,


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.