TODO Octave and Matlab tasks
- State "TODO" from ""
From Darlan Cavalcante
If I understood correctly you always save the output to a file using the function org-babel-octave-wrapper-method, right? Maybe instead of using "%s save -ascii %s ans" to save the information to a file you can use "%s save -text %s ans" I tested this for numbers, strings and matrices and it seems to do the right thing. However, octaves adds some comment lines in the beginning of the file that you will probably need to remove, but you just need to remove lines that start with "#".
Regarding which value is returned, maybe you can use the same approach employed for python, where a line "return variable" is required in the end of the block, instead of just returning the value of ans.
In fact, I don't like to put a return statement in the end of the block just to make babel happy (python included), since I don't want this when I tangle the file, but this is the most flexible way.
Maybe a good feature request for babel it that instead "exports: value" one has to write "exports: value variable" and this would have the effect of the "return variable" in the end of the block that we have right now for python.
Regarding the graphical output, It is probably better to use :results file as suggested in the TODO. There may be necessary a lot of details in the graphic output such as labels, setting axis, etc.. It is better to let the user handle this in the code and just put the link to the file.
DONE Get matlab "Emacs Link" working
- State "DONE" from "TODO"
- State "TODO" from ""
Current solution is imperfect: it involves the matlab process signaling completion by removing a lock file rather than using the canonical org-babel comint completion functions.
DONE How to detect if result is numeric or string?
- State "TODO" from ""
Strings were being returned as their ascii codes.
We have adopted Darlan's suggestion of using save -text %s ans (and delting the comment lines), which seems to provide a solution.
'octave string'
'string from matlab'
TODO How to divert graphical output to file?
- State "TODO" from "" [2010-03-17 Wed 23:3
Currently we are like pyuthon and ruby in that we can use :results file and the block will output a link to that file, but unless your code takes care of it (e.g. write graphics to file), no content will be written to that file.
However, would it be appropriate to move to the org-babel-R model, whereby if :results file is supplied, any graphical is automatically diverted to that file?
Related: getting graphical output from octave
In order to get graphical output without leaving open graph windows during evaluation, the following can be used:
#+begin_src octave :output file :file chart.png figure( 1, "visible" , "off" ); sombrero; print -dpng chart.png #+end_src
The figure
command opens an invisible graph window where the next plot commands should act.
Then, the print
command exports the graph to a file.
TODO Ensure that value is returned when expected
- State "TODO" from ""
In :results value mode, we return whatever value the variable 'ans' has at the end of the block. However, there are some problems with this as can be seen from the following session:
octave> 'hello' ans = hello octave> ans ans = hello octave> x = 19 x = 19 octave> x x = 19 octave> ans ans = hello
So although this works as expected:
z + 0
This doesn't
z
As part of its internal operation, org-babel appends a special end-of-output string at the end of each block and it is this string's value (integer ascii codes) that is being returned here.
Of course, this works
ans
TODO Allow multiple sessions
- State "TODO" from ""
TODO Should we use these by default to save external process startup time?
- State "TODO" from ""
- -nodisplay ?
- -nojvm ?
TODO How to implement :results pp, :results code?
- State "TODO" from ""
TODO How to get rid of the matlab splash message
- State "TODO" from ""
-nosplash doesn't seem to do the trick.
TODO submit patch to matlab.el so that matlab session can be remote
- State "TODO" from ""
At the moment I'm using a massive hack: insert
(cd "/ddavison@tombstone.princeton.edu:") ;; DED
around line 4253 in matlab.el so that my matlab sessions run on a machine with matlab installed.