Main Content

La traduzione di questa pagina non è aggiornata. Fai clic qui per vedere l'ultima versione in inglese.

Handle delle funzioni

Variabili che consentono di chiamare una funzione indirettamente

Un handle di funzione è un tipo di dati MATLAB® che rappresenta una funzione. Un uso tipico degli handle di funzione è quello di passare una funzione a un'altra funzione. Ad esempio, è possibile utilizzare gli handle di funzione come argomenti di input per funzioni che valutano espressioni matematiche su un intervallo di valori.

Gli handle di funzione possono rappresentare funzioni denominate o anonime. Per creare un handle di funzione, utilizzare l’operatore @. Ad esempio, creare un handle a una funzione anonima che valuti l’espressione x2y2:

f = @(x,y) (x.^2 - y.^2);
Per maggiori informazioni, vedere Create Function Handle.

Funzioni

function_handleHandle to function
fevalEvaluate function
func2strConstruct character vector from function handle
str2funcConstruct function handle from character vector
localfunctionsFunction handles to all local functions in MATLAB file
functionsInformation about function handle

Argomenti

  • Create 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.

  • Parameterizing Functions

    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.

  • Compare Function Handles

    The result of comparing equality of function handles depends on what the handle represents and when you created it.