Skip to main content

2.7) User Interface: editor


There is one final important component of your interaction with Matlab that can appear in the interface. Typing commands into the Matlab command line and looking back at the command history can be fine for exploratory work, but what if we want to save our commands or make more complex chunks of code?
We can open an Editor window and type into a text file instead of directly into the command window. Then we can save sequences of commands in a .m file.
Then you can:

  • run bits of your script by highlighting one or more lines, right-clicking and selecting "Evaluate selection"
  • press the "Save and run" button on the toolbar
  • at the command prompt, enter the script name without the .m suffix.

We can start the Matlab editor in a number of different ways:

  • Click on “New” at the top left of the main Matlab window and then “Script”
  • At the command prompt (>>) type “edit”.
  • At the command prompt (>>) type “open filename”, where filename is the name of an existing script file.

Here is a view of the user interface (this time Matlab 2007) with the Editor open (upper central panel):