isobject

Determine if input is MATLAB object

Syntax

tf = isobject(A)

Description

tf = isobject(A) returns true if A is an object of a MATLAB® class. Otherwise, it returns false.

Handle Graphics® objects return false. Use ishghandle to test for Handle Graphics objects.

Instances of MATLAB fundamental classes return false. Use isa to test for any of these types. See Fundamental MATLAB Classes for more on these classes.

Examples

These examples show the values isobject returns when passed specific types:

Define the following MATLAB class:

classdef button < handle
   properties
      UiHandle
   end
   methods
      function obj = button(pos)
         obj.UiHandle = uicontrol('Position',pos,...
            'Style','pushbutton');
      end
   end
end

Determine which objects are MATLAB objects. For example:

h = button([20 20 60 60]);
isobject(h)
ans =
     1
isobject(h.UiHandle)
ans =
     0

Use isjava to test for Java® objects in MATLAB, where it returns false for MATLAB objects:

isjava(h)
ans =
     0

Create an object that is a MATLAB numeric type:

a = pi;
isa(a,'double')
ans =
     1
isobject(a)
ans =
     0

See Also

| |

Tutorials

Was this topic helpful?