MATLAB: How can i check if the axes handles exist or not

axescallbackfind handlesguihandlespushbutton

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?

Best 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.