localfunctions

Function handles to all local functions in MATLAB file

Syntax

Description

example

fcns = localfunctions returns a cell array of function handles, fcns, to all local functions in the current file.

You cannot define local functions in the context of the command line, scripts, or anonymous functions, so when you call localfunctions from these contexts, you get an empty cell array. Within the cell array, localfunctions returns the function handles in an undefined order.

Examples

expand all

Display Handles to Local Functions in File

Create a new file, fileWithLocalFunctions.m, in your MATLAB® path. In the main function, call and display the results of localfunctions. In the same file, create two local functions.

function fileWithLocalFunctions

fcns = localfunctions;
display(fcns)
 
function alocalfunction
 
function anotherlocalfunction

From the command line, call your function.

fileWithLocalFunctions
fcns = 

    @alocalfunction      
    @anotherlocalfunction

More About

See Also

Was this topic helpful?