Modification of handles using functions

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

Example 2:

Matlab




% Code
h = @fun;
integration = integral(h,0,3)
  
%function
function result = fun(x)
    result = (x.^3)/4;
end


Now, here the function handle object h is modified by the inbuilt function integral as a vector to calculate the numerical integration in the given range.

Output:

 

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

...