Generate a script:
To generate a script, click File, then New, and then M-file. The new window will appear known as the Editor. To generate a new script, simply type the series of statements.Whenever finished, save the file using File and then saves. Make sure that the extension .m is on the filename (this must be the default). The rules for filenames are similar as for variables (they should start with a letter, after that there may be letters, digits, or the underscore, etc.). By the default, scripts will be saved in the Work Directory. When you want to save the file in a different directory, the present Directory can be changed.