Programming Previous page   Next Page

Built-In Functions

Functions that are frequently used or that can take more time to execute are often implemented as executable files. These functions are called built-ins.

Unlike M-file functions, you cannot see the source code for built-ins. Although most built-in functions do have an M-file associated with them, this file is there mainly to supply the help documentation for the function. Take the reshape function, for example, and find it on the MATLAB path:

If you type this M-file out, you will see that it consists almost entirely of help text. At the bottom is a call to the built-in executable image.

Identifying Built-In Functions

As with M-file functions, you can identify which functions are built-ins using the exist function. This function identifies built-ins by returning the number 5:

Forcing a Built-In Call

If you overload any of the MATLAB built-in functions to handle a specific data type, then MATLAB will always call the overloaded function on that type. If, for some reason, you need to call the built-in version, you can override the usual calling mechanism using a function called builtin. The expression

forces a call to MATLAB built-in reshape, passing the arguments shown even though an overload exists for the data types in this argument list.


Previous page  MATLAB Functions Overloaded MATLAB Functions Next page

© 1994-2005 The MathWorks, Inc.