Programming |
|
Types of Functions
MATLAB provides the following types of functions. Each function type is described in more detail in a later section of this documentation:
- The Primary M-File Functions is the first function in an M-file and typically contains the main program.
- Subfunctions act as subroutines to the main function. You can also use them to define multiple functions within a single M-file.
- Nested Functions are functions defined within another function. They can help to improve the readability of your program and also give you more flexible access to variables in the M-file.
- Anonymous Functions provide a quick way of making a function from any MATLAB expression. You can compose anonymous functions either from within another function or at the MATLAB command prompt.
- Overloaded Functions are useful when you need to create a function that responds to different types of inputs accordingly. They are similar to overloaded functions in any object-oriented language.
- Private Functions give you a way to restrict access to a function. You can call them only from an M-file function in the parent directory.
You might also see the term function functions in the documentation. This is not really a separate function type. The term function functions refers to any functions that accept another function as an input argument. You can pass a function to another function using a function handle.
| M-File Functions | | Identifying Dependencies | |
© 1994-2005 The MathWorks, Inc.