MATLAB: What is best practice to determine if input is a figure or axes handle

axesfiguregraphicshandlesMATLAB

I've been confused about MATLAB graphics since change to the new graphics system. I do not know how I can check for a variable being a handle to a figure or axes. Functions that come to mind are:
ishandle
isgraphics
ishghandle
isa(x,'matlab.ui.Figure') % x being the variable representing a Figure or Axes
isa(x,'matlab.graphics.axis.Axes') % wow, these really are cumbersome commands!
% etc.
What are best practices to ensure maximal compatibility with most MATLAB versions to detect what kind of input I'm dealing with? Why are there no
isfigure
or
isaxes
functions built-in?

Best Answer

Simples, write those functions yourself, something along the lines:
function OK = isfigure(h)
if strcmp(get(h,'type'),'figure')
OK = 1;
else
OK = 0;
end
You could decorate your code to handle array input, do error checking and make the output proper Boolean output but the core part is to look at the type field of the graphics handle.
HTH