La traducción de esta página está obsoleta. Haga clic aquí para ver la última versión en inglés.
Un identificador de función es un tipo de dato de MATLAB® que representa una función. Comúnmente, los identificadores de función se utilizan para pasar una función a otra. Por ejemplo, se pueden utilizar identificadores de función como argumentos de entrada para las funciones que evalúan expresiones matemáticas en un rango de valores.
Los identificadores de función pueden representar funciones designadas o anónimas. Para crear un identificador de función, use el operador @
. Por ejemplo, cree un identificador para una función anónima que evalúe la expresión x2 – y2:
f = @(x,y) (x.^2 - y.^2);
function_handle | Handle to function |
feval | Evaluate function |
func2str | Construct character vector from function handle |
str2func | Construct function handle from character vector |
localfunctions | Function handles to all local functions in MATLAB file |
functions | Information about function handle |
Use a function handle to create an association to a named function or an anonymous function. Then, you can indirectly call the representative function.
Pass Function to Another Function
You can use function handles as input arguments to
functions that evaluate mathematical expressions over a range of values,
such as integral
and fzero
.
This topic explains how to store or access extra parameters
for mathematical functions that you pass to functions such as fzero
, ode45
,
or integral
.
Call Local Functions Using Function Handles
If a function returns handles to local functions, you can call the local functions outside of the main function. This approach allows you to have multiple, callable functions in a single file.
The result of comparing equality of function handles depends on what the handle represents and when you created it.