When I try to invoke a subfunction in a GUI/GUIDE file (using a function handle which has been exposed as a global variable), a new axes is always created even if I set the axes to a specific axes in the GUIDE figure. Does anyone know why this is happening? GUIDE code is:
###############################################################
function varargout = demo(varargin)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @demo_OpeningFcn, ...
'gui_OutputFcn', @demo_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
function demo_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
global myhandles updateFunction;
myhandles = handles;
updateFunction = @update;
function varargout = demo_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function pushbutton1_Callback(hObject, eventdata, handles)
update();
function update()
global myhandles;
axes(myhandles.axes1);
plot(1:2,1:2);
###########################################################################
And when I do (outside file above):
global updateFunction;
feval(updateFunction)
I always see the plot in a newly created figure window, not in the GUI figure. Why is this happening?