Examples
Create a New Script File
Create a new Script when ever you need to define a new Matlab program (script). Create a file by using the menu or by clicking the New m-Mile button:
or When you create a new script file, the file editor window is opened and a blank screen shows that there is no content in this file yet.
Creating a file does not save it on your computer or on the network file system. You will need to save your file or risk losing any information you type into it. Be sure to understand where (on the network or on your local machine) you save your file. This information is shown in the current directory window. It will only be available from that directory.
Create a New Function File
Create a new Function when ever you need to define a new function. Create a function definition file by using the menu:
When you create a new function file, the file editor window is opened and a "stub function" is outlined for you. This is a nice feature that is intended to help MATLAB users define their functions correctly.
Creating a function file does not save it on your computer or on the network file system. You will need to save your function or risk losing any information you type into it. Be sure to save the function in the same folder as the script (or function) that will call it. It will only be available from that folder.
Save a MATLAB file
Don't forget to save your file(s) often. Use the menu or click the
Save
button and choose a name. For this example, choosetest.m
:or Always save your files as typeMATLAB files (*.m)
to ensure that only the text is saved. The title bar now shows the directory and the name of the file you saved.Open an Existing M-file
Open an existing m-file whenever you need make changes to the statements or commands that it contains. You will need to know which directory it has been saved in. Open a file by using the menu or by clicking the Open m-Mile button:
or Opening a file allows you to make changes to the contents of the file. You will need to save the file after editing the file or risk losing any of the newly typed information.