Josh - since you are programmatically creating your GUI, you could avoid the use of the handles structure and calls to guidata (which may not be applicable to this GUI design). Instead, nest your callback functions within the main GUI function (in this case, the simple_gui2) so that these functions can access the variables declared within the "parent" function. For example, if we add a callback to your surf button, we could then draw something on the axes as
function simple_gui2
% Create a UI
f = figure('Position',[360,500,450,285]);
% Construct the components.
hsurf = uicontrol('Style','pushbutton','String','Surf',...
'Position',[315,220,70,25], 'Callback',@surfCallback);
hmesh = uicontrol('Style','pushbutton','String','Mesh',...
'Position',[315,180,70,25]);
hcontour = uicontrol('Style','pushbutton',...
'String','Contour',...
'Position',[315,135,70,25]);
htext = uicontrol('Style','text','String','Select Data',...
'Position',[325,90,60,15]);
hpopup = uicontrol('Style','popupmenu',...
'String',{'Peaks','Membrane','Sinc'},...
'Position',[300,50,100,25]);
ha = axes('Units','Pixels','Position',[50,60,200,185]);
align([hsurf,hmesh,hcontour,htext,hpopup],'Center','None');
function surfCallback(hSource, eventdata)
[X,Y,Z] = peaks(25);
surf(ha, X, Y, Z);
end
end
Note how ha is used from within the callback. Try the above and see what happens!