From: John Kitchin <jkitchin@andrew.cmu.edu>
To: Uwe Brauer <oub@mat.ucm.es>
Cc: emacs-orgmode@gnu.org
Subject: Re: workflow, matlab+latex in org file
Date: Sat, 11 Mar 2017 08:23:55 -0500 [thread overview]
Message-ID: <m21su43q1g.fsf@VPN-128-237-145-1.LIBRARY.VPN.CMU.EDU> (raw)
In-Reply-To: <87tw70dysj.fsf@mat.ucm.es>
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
next prev parent reply other threads:[~2017-03-11 13:24 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-11 12:32 workflow, matlab+latex in org file Uwe Brauer
2016-07-11 14:05 ` John Kitchin
2016-07-11 14:11 ` Uwe Brauer
2016-07-11 15:55 ` John Kitchin
2016-07-11 16:12 ` Uwe Brauer
2017-03-10 16:08 ` Uwe Brauer
2017-03-10 17:51 ` Scott Randby
2017-03-10 21:15 ` Uwe Brauer
2017-03-10 21:56 ` John Kitchin
2017-03-10 22:50 ` Uwe Brauer
2017-03-10 23:17 ` SOLVED (was: workflow, matlab+latex in org file) Uwe Brauer
2017-03-11 23:50 ` workflow, matlab+latex in org file Scott Randby
[not found] ` <5e1e71e3698e415ca51a0b9e3cab5dac@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2017-03-10 18:03 ` Eric S Fraga
2017-03-10 21:18 ` Uwe Brauer
2017-03-11 8:04 ` Uwe Brauer
2017-03-11 13:23 ` John Kitchin [this message]
2017-03-11 14:16 ` Uwe Brauer
2017-03-11 14:22 ` John Kitchin
2017-03-11 14:54 ` Uwe Brauer
2017-03-11 16:50 ` Uwe Brauer
2017-03-11 16:53 ` John Kitchin
2017-03-12 15:24 ` matlab-shell-run-command (was: workflow, matlab+latex in org file) Uwe Brauer
2017-10-20 11:03 ` workflow, matlab+latex in org file Uwe Brauer
2017-10-20 11:54 ` Uwe Brauer
[not found] ` <cf7ef1dfa1cf455bbaf63ab5fbdf18e5@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2017-03-11 10:37 ` Eric S Fraga
2017-03-11 14:12 ` Uwe Brauer
[not found] <m2eg709w4s.fsf@gmail.com>
2016-07-11 13:55 ` Uwe Brauer
[not found] <c0b96d809e4b41529f81beaa685a9fd0@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2016-07-11 16:42 ` Eric S Fraga
2016-07-12 12:44 ` Uwe Brauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m21su43q1g.fsf@VPN-128-237-145-1.LIBRARY.VPN.CMU.EDU \
--to=jkitchin@andrew.cmu.edu \
--cc=emacs-orgmode@gnu.org \
--cc=oub@mat.ucm.es \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).