Programming and Data Types | ![]() ![]() |
Displaying Function Handle Information
The functions
command returns information about a function handle that might be useful for debugging. Calling functions
on a function handle returns the function name, type, filename, and all of the methods for the function that were in scope at the time the function handle was created.
The information returned from functions
is in the form of a MATLAB structure. The fields of this structure are listed in the following table.
Field Name |
Field Description |
function |
Function name. |
type |
Function type. See the table in Function Type. |
file |
The file to be executed when the function handle is evaluated with a nonoverloaded data type. For built-in functions, it reads 'MATLAB built-in function .' |
methods |
All overloaded methods of the function that are bound to the function handle. This field exists only for functions of type, overloaded . |
For example, to obtain information on a function handle for the display
function,
f = functions(@display) ans = function: 'display' type: 'overloaded' file: 'MATLAB built-in function' methods: [1x1 struct]
Individual fields of the structure are accessible using the dot selection notation used to access MATLAB structure fields.
The methods
field is a separate structure containing one fieldname for each class that overloads the function. The value of each field is the path and name of the file that defines the function.
f.methods ans = polynom: '\home\user4\@polynom\display.m' inline: 'matlabroot\toolbox\matlab\funfun\@inline\display.m' serial: 'matlabroot\toolbox\matlab\iofun\@serial\display.m' avifile: 'matlabroot\toolbox\matlab\iofun\@avifile\display.m' f.methods.polynom ans = polynom: '\home\user4\@polynom\display.m'
Note
The functions command does not operate on nonscalar function handles. Passing a nonscalar function handle to functions results in an error.
|
![]() | Examples of Function Handle Evaluation | Fields Returned by the Functions Command | ![]() |