On 13/08/17 10:33, Uwe Brauer wrote:
Hi

I would like to execute some matlab code in org file (using GNU emacs 26
and the git version of org mode) and save the result of the plot command
in a png file, so I tried

#+begin_src matlab :session :exports both :file testplot.png
t=[0:0.1:1];
y=sin(t);
plot(t,y)
print -dpng  testplot.png
#+end_src

And also
#+begin_src matlab :results output latex :exports results  :file testplot.png
t=[0:0.1:1];
y=sin(t);
plot(t,y)
print -dpng  testplot.png
#+end_src

But the resulting png files are corrupt. I presume also the matlab
commands are included in the png file which is not correct. But I don't
know who to achieve that just the last command is saved in a png file.

I guess the problem is that the Matlab line "print -dpng testplot.png" is correctly writing the plot to testplot.png, as you want, but then org-mode is overwriting that file because of the ":file testplot.png". I would try deleting ":file testplot.png".

The meaning of ":results output" may be a bit language-dependent - I don't know org-mode well enough to be sure about that yet - but in general I would expect it to consist of the standard output of those commands. So, for example, if you type "print -dpng testplot.png" and Matlab responds with "Generated 'testplot.png'", I would expect ":results output" to contain "Generated 'testplot.png'", not the PNG data.

Regards - Neil


Reply via email to