You might dig around in ob-octave to see how it works. It should be able to Matlab (and on Linux/Mac I believe it might). On Windows, it has been broken for a long time due to the lack of a proper shell (maybe that can be adapted in win10 though).
I vaguely recall making that matlab function to try it out on Windows some years ago. There is a Jupyter Matlab kernel now. https://github.com/Calysto/matlab_kernel I was able to use this (and installing the kernel, and making sure a matlab is on the path): #+BEGIN_SRC emacs-lisp (add-to-list 'org-src-lang-modes '("matlab" . matlab)) ;; set default headers for convenience (setq org-babel-default-header-args:matlab '((:results . "output replace") (:session . "matlab") (:kernel . "matlab") (:exports . "code") (:cache . "no") (:noweb . "no") (:hlines . "no") (:tangle . "no"))) (defalias 'org-babel-execute:matlab 'org-babel-execute:ipython) (defalias 'org-babel-prep-session:matlab 'org-babel-prep-session:ipython) (defalias 'org-babel-matlab-initiate-session 'org-babel-ipython-initiate-session) #+END_SRC #+RESULTS: : org-babel-matlab-initiate-session To enable this: #+BEGIN_SRC matlab :results output org drawer x = [1, 2, 3, 4, 5]; fprintf('|%d', x) #+END_SRC #+RESULTS: :RESULTS: | 1 | 2 | 3 | 4 | 5 | :END: It is not much better output wise without the fprintf, but that seems to be a feature of Matlab's output. I think Eric is probably right, you will have use fprintf to get what you want. I am not a big matlab user these days, so I do not have a sense for how usable the kernel is. It does run in a session, which is a big improvement over the other one I wrote. Uwe Brauer writes: > > On Friday, 10 Mar 2017 at 16:08, Uwe Brauer wrote: > > > [...] > > > > You may need to add ":exports results" to the src line. > > > Also, you should also modify the code to wrap the output in an equation > > environment: > > > disp('\begin{equation}') > > disp(ltxjac) > > disp('\end{equation}') > > > I played a bit more around, and John's code is a great help but the > matlab output for non symbolic variables is just awful > > As in > #+begin_src matlab :results output > clear all; > x=[ 1 2 2 3 4] > #+end_src > > #+RESULTS: > : > : x = > : > : 1 2 2 3 4 > : > > Does anybody know how to get a better formatted output, to get rid of > the empty lines and newline? best would be a org-table? > > org-table-convert-region results in > > | : 1 2 2 3 4 | > > Uwe Brauer -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu