4. M files

In addition to executing commands entered through the keyboard, you can also use commands stored as files. These files all end in the extension .m and are called M-files because of the file name extension. Long programs are usually created in a text editor and stored as an M-file that can be executed in a MATLAB session. Short programs are usually created and run directly on-line.

M files are of two types: script m file and function m file. Function m file starts with the keyword function.