Cornell University Cornell University CISER

CISER Computing

Running Matlab Jobs in Batch Mode

General Instructions for Running a Matlab Job in Batch Mode in Windows.

Example: Running a Matlab job in batch mode on a research server.

  1. Use the Matlab M-file editor (or other text editor) to create your ".m" file:
    • Be sure that the filename extension is .m.
    • Be sure to include the command "exit" as the last command in the file.
  2. Open a command window on the research server desktop:
    • From Windows go to Start→Run→ and type: "Command"→OK.
    • OR go to Start→All Programs→Accessories→Command Prompt.
  3. In the command window change to the directory which contains your ".m" file:
    • First change to the correct drive by typing U: at the prompt and then press "enter".
    • Then change directory to the folder you wish to use:
      • examples:
        • cd desktop\census
        • cd "documents\my mfiles"
      • Note: if you have a space in your folder name, enclose the entire path in double quotes.
    • Run the matlab job from the command line as follows:
      • type at the prompt:
        • matlab   -nosplash   -r   [a,b,c]=myarray   -logfile   myarray.log
        • Where "myarray"  refers to the .m file ("myarray.m") in the current working directory, and "myarray.log" is the log file that will contain the output that would usually be generated in the Matlab window if run in interactive mode.