Getting Started |
Function Functions
A class of functions called "function functions" works with nonlinear functions of a scalar variable. That is, one function works on another function. The function functions include
MATLAB represents the nonlinear function by a function M-file. For example, here is a simplified version of the function humps
from the matlab/demos
directory.
Evaluate this function at a set of points in the interval 0 x 1 with
The graph shows that the function has a local minimum near x = 0.6. The function fminsearch
finds the minimizer, the value of x where the function takes on this minimum. The first argument to fminsearch
is a function handle to the function being minimized and the second argument is a rough guess at the location of the minimum.
To evaluate the function at the minimizer,
Numerical analysts use the terms quadrature and integration to distinguish between numerical approximation of definite integrals and numerical integration of ordinary differential equations. MATLAB quadrature routines are quad
and quadl
. The statement
computes the area under the curve in the graph and produces
Finally, the graph shows that the function is never zero on this interval. So, if you search for a zero with
you will find one outside the interval
Function Handles | Vectorization |
© 1994-2005 The MathWorks, Inc.