This file contains notes on using Matlab and Octave with Org-babel.
An example of an octave block in Org-babel is
#+begin_src octave :exports results ,n = [1:10]; ,x = 5*n+4; ,ans = x #+end_src ,| 9 | 14 | 19 | 24 | 29 | 34 | 39 | 44 | 49 | 54 |
Notice that the final line is "ans = x". Finishing the block with the simple statement "x" will not work. In Org-babel, Matlab and Octave return the result of the special variable "ans", which (in Octave at least) is automatically updated with "The most recently computed result that was not explicitly assigned to a variable". Therefore, both "ans =x" and "x + 0" would result in the desired result being returned, "x" alone will not.
In order to get graphical output without leaving open graph windows during evaluation, the following can be used:
figure( 1, "visible", "off" ); sombrero; print -dpng chart.png; ans = "chart.png";
figure command opens an invisible graph window where the next plot commands should act.
:results file says to interpret the result as a file path.