Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • In the "Command Window" in the middle of the matlab window, type "1+1" and hit return, it should say "2".
  • Click the "New Script" button at the upper left (or the "New" Button, then select "Script" if you don't see "New Script").
    • This will open an editing window for a script. 
  • Type "1+1" in the window, then click "Save" from the upper menu. 
    • Name it anything with a ".m" extension (such as untitled.m, the default). 
  • You can then use then "Open" menu, or the "Current Folder" pain, to open that file in the future.
  • Once open in the Editor, you can use the "Run" command from the Editor menu to run it.
  • Exit matlab (using either the "exit" or "quit" command)

To open matlab without the graphical interface, type the not-so-short or intuitive command: matlab -nodisplay -nosplash. This should give an interactive command prompt. To exit, type quit or exit. Other sometimes-useful options for the non-GUI matlab include -nojvm (might speed things up a bit) and -wait (wait until your jobs finish before exiting).

To run the "script" we created above (called untitled.m in your home directory) and exit, you can do something like:

Code Block
languagebash
matlab -nodisplay -nosplash -r "run('~/untitled.m');quit"

To add some error checking, you can try either ofuse:

Code Block
languagebash
matlab -nodisplay -nosplash -r "try, run('~/untitled.m'), catch, exit, end, exit"

...

Code Block
languagebash
echo "5^3/(2^4+1)" > ~/untitled2.m
matlab -nodisplay -nosplash -nojvm -r "run('~/untitled2.m');quit"

...