8.7. Function Handles

As about Handle Graphics® a function handle stores all the information about the function which is needed for its execution later. A function handle can be created by any of the following two ways:

8.7.1. Using @ Operator

Suppose it is desired to create a function f(t) = 4e−2t, for t in the range of 0 to 5. This function can be defined as follows:

Function timres = func(t)
timres = 4 * exp(-2 * t)
end

Function handle can be created by the following line:

handl = @func

where handl is the name of the function handle and func is the name of the function. The function func(t) can now be executed by just typing the name of the function handle and enclosing the arguments in the parentheses. ...

Get MATLAB® and Its Applications in Engineering: [Based on MATLAB 7.5 (R2007b)] now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.