Skip to main content

11.1) Scripts


  • So far we have worked on the Matlab command line using simple commands
  • What if we want to save our commands or make more complex codes
  • We can store sequences of commands in a .m file
  • Anything that you can enter at the Matlab command prompt you can put into a script file
  • Script files are run at the command prompt by entering the script name without the .m suffix
  • We edit .m files in the Matlab editor
  • We can start the Matlab editor a number of different ways
    1. Click on "New" at the top left of the main Matlab window and then "Script"
    2. At the command prompt (>>) type "edit"
    3. At the command prompt (>>) type "open filename", where filename is the name of an existing script file