Difference between revisions of "Mathematica/Note"

From ScientificComputing
Jump to: navigation, search
(Created page with "Note that in batch mode, Mathematica notebooks can not be used, because the Mathematica kernel expects a plain text file with Mathematica commands. These plain text files are...")
 
 
Line 2: Line 2:
  
 
  a = ... [expression] ...
 
  a = ... [expression] ...
  Print["a = "]</code>           -> prints a label
+
  Print["a = "]          -> prints a label
  Print[a]</code>               -> prints the value of a
+
  Print[a]                -> prints the value of a
  
 
You can also use graphical commands as Plot or Display in the batch mode. This is discussed below, but first it is explained, how to use Mathematica in batch mode, when no graphical commands are involved.
 
You can also use graphical commands as Plot or Display in the batch mode. This is discussed below, but first it is explained, how to use Mathematica in batch mode, when no graphical commands are involved.

Latest revision as of 07:35, 25 August 2016

Note that in batch mode, Mathematica notebooks can not be used, because the Mathematica kernel expects a plain text file with Mathematica commands. These plain text files are called script file and their name ends with .m (for instance input.m). The output has then to be redirected to an output file. In interactive mode, you type an expression, and the result is immediately displayed on your screen. In batch mode you have ensure that Mathematica writes labels and results to your output file. Therefore you need to assign your expression to a variable and use afterwards the Print[] command.

a = ... [expression] ...
Print["a = "]           -> prints a label
Print[a]                -> prints the value of a

You can also use graphical commands as Plot or Display in the batch mode. This is discussed below, but first it is explained, how to use Mathematica in batch mode, when no graphical commands are involved.