Guest
Hi anyone,
My application contains a graphic called ‘AxeSpot’. To show it I push a button. The button’s callback executes the following code:
% Get the main figure’s handle
hfmain=findobj('Tag','FigMain'); % Main Figure’s handle.
% Create the ‘AxeSpot’ axes (which is a main figure’s child) with certains properties.
h1 = axes('Parent',hfmain, ...
'Units','pixels', ...
'Position',[181 228 177 104], ...
'Tag','AxeSpot', ...
'Color',[1 1 1], ...
'Layer','top', ...
'Visible','on',...
'XColor',[1 1 1], ...
'YColor',[1 1 1]);
hspot=findobj('Tag','AxeSpot'); % This sentence asign a handle to ‘AxeSpot’ axes.
axes(hspot); % This sentence select ‘AxeSpot’ as current axes.
set(hspot,'NextPlot','add'); % This sentence add the nexplot to ‘AxeSpot’ axes.
spot(v_out); % This is the function that show the plot over the %‘AxeSpot’ axes.
But there is a trouble: The first time I push the button, the graphics is created and the plot is added to ‘AxeSpot’ axes. However, the following times I push the button, the program does not work and an error arises. The error says: hfmain invalid handle in line …. The program line of which I talk is that where I create the axes again:
h1 = axes('Parent',hfmain, ...
'Units','pixels', ...
'Position',[181 228 177 104], ...
.
.
.
.
Which is the problem reason? Why does it not work? Do you know how to solve it?
Thanks in advance,
Cris