scurvy - the error message is telling you that the callback function onFileOpen (and onFileExit) cannot be found either because the file is not within the MATLAB search path or it doesn't exist (i.e. no file named onFileOpen.m). I suspect that the latter is true.
What you need to do is either create the callbacks in files named onFileOpen.m and onFileExit.m, or define the functions within your script as follows
function mainGui
hMainMenu=uimenu('Label','&File');
hOpenMenu=uimenu(hMainMenu,'Label','Open...','CallBack',@onFileOpen);
uimenu(hMainMenu,'Label','Exit','CallBack',@onFileExit);
function onFileOpen(hObject, eventdata)
fprintf('onFileOpen called\n');
end
function onFileExit(hObject, eventdata)
fprintf('onFileExit called\n');
end
end
Note how the callbacks are nested within the main (parent) GUI function. See nested function for a description of thee types of functions and their benefits (notably the sharing of variables between the parent and nested function).
An alternative to the above, which could be easier for a new user of MATLAB, is to use GUIDE to create your GUI. See creating a simple GUI with GUIDE for one such example.
