11.1 Introduction to Function and Script Files
There are seven different things covered in this section.
- Typing in a function at the command prompt.
- Storing a group of commands in a file — called a script file.
- Storing a function in a file—called a function file.
- Subfunctions in function files.
- Multiple functions in one script file.
- Private functions.
- 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.
© 1996–2020 John W. Eaton
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.
https://octave.org/doc/v5.2.0/Introduction-to-Function-and-Script-Files.html