|Programming and Data Types|
Fields Returned by the Functions Command
functions command returns a MATLAB structure with the fields
file, and, for overloaded functions,
methods. This section describes each of those fields.
function field is a character array that holds the name of the function corresponding to the function handle.
type field is a character array that holds one of five possible strings listed in the following table.
||Nonoverloaded MATLAB built-in or M-file, or any function for which the
||MATLAB private function
||Constructor to a MATLAB class
||Overloaded built-in, M-file function, or constructor
The contents of the next two fields,
methods, depend upon the function
file field is a character array that holds one of the following:
MATLAB built-in function', for built-in functions
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
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
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:
avifile. For each class, it shows the path and name of the method source file.
The set of methods returned by |
|Displaying Function Handle Information||Types of Function Handles|