Checking whether an object is a handle or not

We can check whether an object is a handle or not by using the is a() function.

Syntax

isa(object-name, ‘handle’)

it is a Boolean function and returns true if the object is a handle. See the example below to understand.

Example 5:

Matlab




% Code
ax = axes;
x=22;
fprintf('checking for object handle ax:')
disp(isa(ax,'handle'))
fprintf('checking for some variable x: ')
disp(isa(x,'handle'))


In this example, we create an axes object and a variable. Then we check with is a() for the object handle. The output will be in Boolean as follows.

Output: 

 

As it can be seen, ax is a handle however, x is not. 



Handle Object Behavior in MATLAB

Handles in MATLAB are data type that points to an object. The handles can be used to point to an object from different references or to pass a function to another function as an input argument.

We shall not explain the creation and usage of MATLAB handles, as they are out of this article’s scope. However, MATLAB handles have some special properties that we shall discuss in this article.

Similar Reads

Copies of a MATLAB handle

When a copy of a handle object is created, it still points to the same object as the original handle. See the following example to understand it better....

Modification of handles using functions

...

Deletion of handle object

MATLAB allows to modification of the handles as arguments to functions, which directly accesses the object referred to by the function....

Checking whether an object is a handle or not

...