Next: , Up: Functions and Scripts   [Contents][Index]

11.1 Introduction to Function and Script Files

There are seven different things covered in this section.

  1. Typing in a function at the command prompt.
  2. Storing a group of commands in a file — called a script file.
  3. Storing a function in a file—called a function file.
  4. Subfunctions in function files.
  5. Multiple functions in one script file.
  6. Private functions.
  7. Nested functions.

Both function files and script files end with an extension of .m, for MATLAB compatibility. If you want more than one independent functions in a file, it must be a script file (see Script Files), and to use these functions you must execute the script file before you can use the functions that are in the script file.