axes problem in MATLAB gui

3 views (last 30 days)
Neo
Neo on 15 Sep 2012
Commented: Adam on 21 Aug 2014
Error using ==> axes
Invalid object handle
Error in ==> final>pushbutton14_Callback at 1030 axes(handles.axes1);
WHen i first run the program it worked. But when i click it again, the error appeared? How can i solve this problem?
  4 Comments
Juan David Cano-Moreno
Juan David Cano-Moreno on 21 Aug 2014
Edited: Juan David Cano-Moreno on 21 Aug 2014
The problem using axes(handles.axes1) is that Matlab sometimes loose this reference. You can remind them, using an expression like:
if true
% code
end
axes(handles.axes1)
plot(x,y);% Also with subplots
handles.axes1=gca;
Regards.
Adam
Adam on 21 Aug 2014
Is axes1 embedded in your GUI or is it one you spawned earlier and stored in the handles structure?

Sign in to comment.

Answers (1)

Jan
Jan on 15 Sep 2012
Either handles.axes1 is replaced by an invalid handle, or the corresponding axes object has been deleted. Use the debugger to find out more details, e.g.:
dbstop if error
Then run the function again. Matlab stops when the error occurs, such that you can inspect the value of handles.axes1 manually. If the problem is the deleting of the axes object, check the code until you find the corresponding command - perhaps a clf?
  2 Comments
Neo
Neo on 16 Sep 2012
i removed cla from my program. but the problem still persists. :(
Image Analyst
Image Analyst on 16 Sep 2012
Look for "clear" or similar, such as "clear all" "clearvars" etc.

Sign in to comment.

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!