MATLAB: How to identify ui component classes that other ui components can be children of


I am trying to identify ui components like uipanels, uigridlayouts, uitabs, etc., that may contain other ui components as children.
Right now I'm just testing if the class name contains "matlab.ui.container" or is a figure:
contains(class(o),'matlab.ui.container') || isa(o,'matlab.ui.Figure') ...
Is there a better way?

Best Answer

  • You can also use the 'Children' property of UI components.
    This property contains list of child component objects if any, it is empty otherwise.
    For example, you can refer to this documentation for 'uifigure' properties and 'uipanel' properties :
    You can check if this property is empty or has some components under it.