
Lecture 28

Recap
Functions with No input OR No output
Determining The Number of Input and Output Arguments
Local Variables
Global Variables
Creating ToolBox of Functions
Anonymous Functions and Function Handles
Function Functions
Subfunctions

Summary of Chapter
MATLAB contains a wide variety of built-in functions
However, you will often find it useful to create your own
MATLAB functions
The most common type of user-defined MATLAB
function is the function M-file, which must start with a
function-definition line that contains
the word function
a variable that defines the function output
a function name
a variable used for the input argument

Continued….
The function name must also be the name of the M-file in
which the function is stored
Function names follow the standard MATLAB naming
rules
Like the built-in functions, user-defined functions can
accept multiple inputs and can return multiple results
Comments immediately following the function-definition
line can be accessed from the command window with the
help command
Variables defined within a function are local to that
function. They are not stored in the workspace and cannot
be accessed from the command window

Continued….
Groups of user-defined functions, called “toolboxes,” may
be stored in a common directory and accessed by
modifying the MATLAB® search path. This is
accomplished interactively with the path tool, either from
the menu bar, as in
File -> Set Path
or from the command line, with pathtool
MATLAB provides access to numerous toolboxes
developed at The MathWorks or by the user community
Another type of function is the anonymous function,
which is defined in a MATLAB session or in a script M-