”;
MATLAB allows you to write a series of commands into a file and execute the file as a complete unit, like writing a function and calling it. It is done using M-file.
M-File also called as the script file is a series of MATLAB commands that will get executed sequentially when the file is executed.
The m-file is saved with .m extension.
Program Files
MATLAB allows writing two kinds of program files, which are as follows −
Scripts
Script files are program files with .m extension. In these files, you write a series of commands, which you want to execute together. Scripts do not accept inputs and do not return any outputs. They operate on data in the workspace.
A script file looks as follows −
Functions
Function files are also program files with .m extension. Functions can accept inputs and return outputs. Internal variables are local to the function.
A function file looks as follows −
Let us understand how to create and run the m-file in the next chapters.
”;