Programming and Data Types    

Fields Returned by the Functions Command

The functions command returns a MATLAB structure with the fields function, type, file, and, for overloaded functions, methods. This section describes each of those fields.

Function Name

The function field is a character array that holds the name of the function corresponding to the function handle.

Function Type

The type field is a character array that holds one of five possible strings listed in the following table.

Function Type
Type Description
simple
Nonoverloaded MATLAB built-in or M-file, or any function for which the type cannot be determined until it is evaluated
subfunction
MATLAB subfunction
private
MATLAB private function
constructor
Constructor to a MATLAB class
overloaded
Overloaded built-in, M-file function, or constructor

The contents of the next two fields, file and methods, depend upon the function type.

Function File

The file field is a character array that holds one of the following:

The default function is the one function implementation that is not specialized to operate on any particular data type. Unless the arguments in the function call specify a class that has a specialized version of the function defined, it is the default function that gets called.

The example below operates on a function handle for the deblank function. The function has a default implementation in the strfun directory. This is shown in f.file. It also has an overloaded method in the @cell directory. This is shown in f.methods.cell.

If you evaluate the @deblank function handle with a cell argument, MATLAB calls the deblank method in the @cell directory. But, for any other argument types, MATLAB calls the default M-file shown in the file field.

Function Methods

The methods field exists only for functions of type, overloaded. This field is a separate MATLAB structure that identifies all overloaded methods that are bound to the function handle.

The structure contains one field for each method of the function handle. The field names are the classes that overload the function. Each field value is a character array holding the path and name of the source file that defines the method.

For example, a function handle for the display function may be bound to the M-files shown below. The functions command returns a methods structure having a field for each class overloading the function: polynom, inline, serial, and avifile. For each class, it shows the path and name of the method source file.


  Displaying Function Handle Information Types of Function Handles