octave> > > error: fprintf: wrong type argument 'class'
error: called from
dlmwrite at line 195 column 7
This is because you assigned a value of type
sym to the variable
fprintf(), which is a part of wrapping code while Org Babel is evaluating it, is trying to write the given
ans but because the value of
ans isn't class
char and it complains about it. See
ob-octave.el for the wrapping code.
The Org Manual 9.4
(info "(org) Results of Evaluation") says:
Collection options specify the results. Choose one of the options;
they are mutually exclusive.
Default for most Babel libraries(1). Functional mode. Org gets the value by wrapping the code in a function definition in the language of the source block. That is why when using
:results value, code should execute like a function and return a value. For languages like Python, an explicit
return statement is mandatory when using
:results value. Result is the value returned by the last statement in the code block.
When evaluating the code block in a session (see *note Environment of a Code Block::), Org passes the code to an interpreter running as an interactive Emacs inferior process. Org gets the value from the source code interpreter’s last statement output. Org has to use language-specific methods to obtain the value. For example, from the variable
_ in Ruby, and the value of
.Last.value in R.
Scripting mode. Org passes the code to an external process running the interpreter. Org returns the contents of the standard output stream as text results.
When using a session, Org passes the code to the interpreter running as an interactive Emacs inferior process. Org concatenates any text output from the interpreter and returns the collection as a result.
For Octave, with value, you either
- a) assign the value you want to return to Org buffer to the variable
- b) evaluate without assigning it to any variable so that the interpreter assign your value to the automatic variable
Unfortunately, the current
ob-octave doesn't parse class
sym well. This leaves you to use output instead.
With output, you just get everything back from the interpreter.
Getting a Result
Thus, with the following code block:
#+begin_src octave :session :results output
pkg load symbolic
g = (x+1)/sqrt(x^2 - 1)
You get this
octave> g = (sym)
x + 1
╲╱ x - 1
ans = (sym)
(x - 1)⋅╲╱ x - 1
Unfortunately, the current Babel Octave doesn't support result types. Thus,
verbatim, or any other type, doesn't work at all.
These might change in the future if someone fixed them.
This result was produced with
(org-version nil t)
"Org mode version 9.4.6 (release_9.4.6-628-g366444 @ /home/yashi/src/org-mode/lisp/)"