Getting Started    

Function Handles

You can create a handle to any MATLAB function and then use that handle as a means of referencing the function. A function handle is typically passed in an argument list to other functions, which can then execute, or evaluate, the function using the handle.

Construct a function handle in MATLAB using the at sign, @, before the function name. The following example creates a function handle for the sin function and assigns it to the variable fhandle.

Evaluate a function handle using the MATLAB feval function. The function plot_fhandle, shown below, receives a function handle and data, and then performs an evaluation of the function handle on that data using feval.

When you call plot_fhandle with a handle to the sin function and the argument shown below, the resulting evaluation produces a sine wave plot.


  Preallocation Function Functions