This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
m-file_script [2015/05/06 11:48] petersen |
— (current) | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== M_File (Script) ===== | ||
| - | It is possible to use the command window to type in every line of code, but it is not an efficient method if the user wants to reuse the same lines of code multiple times. To help organize code we want to reuse we use a script. You can think of a script as a program you are writing like the programs you wrote when you learned C++. | ||
| - | |||
| - | You can open up a script by selecting the “New Script” button located at the upper left corner of the screen. | ||
| - | |||
| - | {{ :m_script1.png?600 |}} | ||
| - | |||
| - | Once the new script has been opened, your screen should look like the image below. Notice how new tabs appeared, and the user is currently in the editor tab. | ||
| - | |||
| - | {{ :m_script2.png?600 |}} | ||
| - | |||
| - | To save the scripts click save >> save as. Then navigate to the folder where you want to save it, and change the name. Make sure that the file time is a .m else Matlab won’t be able to run it. | ||
| - | |||
| - | Even though nothing has been entered in the script press the “run button” under the editor tab. | ||
| - | The Matlab editor will ask you if you want to change folders if you saved it in a different folder than the one Matlab is currently in. If it is in a different folder, hit “Change Folder”. The script will now run. | ||
| - | |||
| - | {{ :m_script3.png?600 |}} | ||
| - | |||
| - | |||
| - | |||