MATLAB Answers

0

how can i check if the axes handles exist or not ?

Asked by Vasishta Bhargava on 5 Aug 2018
Latest activity Edited by Vasishta Bhargava on 6 Aug 2018
Accepted Answer by Jan
I have GUI which has several pushbuttons. The pushbutton create handles to axes. I want to check if the specific handle or set of handles exist and then write necessary code whether to delete the handle or not ? how can I do it?

  0 Comments

Sign in to comment.

1 Answer

Answer by Jan
on 5 Aug 2018
Edited by Jan
on 5 Aug 2018
 Accepted Answer

if isgraphics(handles.axes1)
In Matlab versions older than R2014b:
if ishghandle(handles.axes1)
I'd prefer ishghandle, because isgraphics accepts integer handles also, which is less reliable in my opinion.

  4 Comments

Show 1 older comment
Where did you expect to plot it? Not in f1 since you deleted that axes. So it would plot in whatever now became the current axes. If there was no other axes left, it would have created one.
You can pass the axes handle into plot() you know.
It is not clear, what you expect ishandle(handle,'f1') to do. What is "handle"? Why do you expect ishandle to accept a second input argument called 'f1'? See: doc ishandle to see, that you do not use this command correctly. If it does not show an error, maybe you do not run the code at all?
Did you read my answer?
if isgraphics(handles.f1)
seems to be better.
@Jan, yeah, ishandle() function has only ONE input argument and also isgraphics() works better than ishandle() ... it works fine now. thanks for the solution.

Sign in to comment.