From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: workflow, matlab+latex in org file Date: Sat, 11 Mar 2017 14:22:46 +0000 Message-ID: References: <8760sc8ids.fsf@mat.ucm.es> <87shvg6z9i.fsf@mat.ucm.es> <5e1e71e3698e415ca51a0b9e3cab5dac@HE1PR01MB1898.eurprd01.prod.exchangelabs.com> <87h931qa9f.fsf@ucl.ac.uk> <87tw70dysj.fsf@mat.ucm.es> <8737ejoq44.fsf@mat.ucm.es> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a114b318ef4f66a054a753638 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cmhvC-0006sP-Vi for emacs-orgmode@gnu.org; Sat, 11 Mar 2017 09:23:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cmhv8-0002ke-SD for emacs-orgmode@gnu.org; Sat, 11 Mar 2017 09:23:02 -0500 Received: from mail-wm0-f44.google.com ([74.125.82.44]:35416) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cmhv8-0002kN-HM for emacs-orgmode@gnu.org; Sat, 11 Mar 2017 09:22:58 -0500 Received: by mail-wm0-f44.google.com with SMTP id v186so13094146wmd.0 for ; Sat, 11 Mar 2017 06:22:58 -0800 (PST) In-Reply-To: <8737ejoq44.fsf@mat.ucm.es> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org --001a114b318ef4f66a054a753638 Content-Type: text/plain; charset=UTF-8 The kernel provides a "session" so matlab stays alive and doesn't have to restart on every block. The kernel might require python3. On Sat, Mar 11, 2017 at 9:20 AM Uwe Brauer wrote: > > > 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 > > > Thanks for pinting it out to me. Couldn't install it so far > ImportError: No module named pathlib > when trying directly to use >python -m matlab_kernel install > > Or ould not find a version that satisfies the requirement > backports.tempfile (from matlab-kernel) (from versions: 1.0rc1, 1.0rc1) > Cleaning up... > No distributions matching the version for backports.tempfile (from > matlab-kernel) > Storing debug log for failure in /home/oub/.pip/pip.log > > Have to write the author. > > The output using your code and Eric's suggestion is ok but I am curious > to see what the kernel is supposed to do better. > > Uwe > > 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: > > > > -- John ----------------------------------- 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 --001a114b318ef4f66a054a753638 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
The kernel provides a "session" so matlab stays alive and do= esn't have to restart on every block.=C2=A0

Th= e kernel might require python3.=C2=A0
On= Sat, Mar 11, 2017 at 9:20 AM Uwe Brauer <oub@mat.ucm.es> wrote:
<= br class=3D"gmail_msg"> =C2=A0 =C2=A0> You might dig around in ob-octave to see how it works. It= should be able
=C2=A0 =C2=A0> to Matlab (and on Linux/Mac I believe it might). On Windo= ws, it has been
=C2=A0 =C2=A0> broken for a long time due to the lack of a proper shell = (maybe that can
=C2=A0 =C2=A0> be adapted in win10 though).

=C2=A0 =C2=A0> I vaguely recall making that matlab function to try it ou= t on Windows
=C2=A0 =C2=A0> some years ago.

=C2=A0 =C2=A0> There is a Jupyter Matlab kernel now.
=C2=A0 =C2=A0> https://github.com/Ca= lysto/matlab_kernel


Thanks for pinting it out to me. Couldn't=C2=A0 install it so far
ImportError: No module named pathlib
when trying directly to use >python -m matlab_kernel install

Or ould not find a version that satisfies the requirement backports.tempfil= e (from matlab-kernel) (from versions: 1.0rc1, 1.0rc1)
Cleaning up...
No distributions matching the version for backports.tempfile (from matlab-k= ernel)
Storing debug log for failure in /home/oub/.pip/pip.log

Have to write the author.

The output using your code and Eric's suggestion is ok but I am curious=
to see what the kernel is supposed to do better.

Uwe
=C2=A0 =C2=A0> I was able to use this (and installing the kernel, and ma= king sure a
=C2=A0 =C2=A0> matlab is on the path):

=C2=A0 =C2=A0> #+BEGIN_SRC emacs-lisp
=C2=A0 =C2=A0> (add-to-list 'org-src-lang-modes '("matlab&q= uot; . matlab))

=C2=A0 =C2=A0> ;; set default headers for convenience
=C2=A0 =C2=A0> (setq org-babel-default-header-args:matlab
=C2=A0 =C2=A0>=C2=A0 =C2=A0 =C2=A0 =C2=A0'((:results . "output = replace")
=C2=A0 =C2=A0>=C2=A0 =C2=A0 (:session . "matlab")
=C2=A0 =C2=A0>=C2=A0 =C2=A0 (:kernel . "matlab")
=C2=A0 =C2=A0>=C2=A0 =C2=A0 (:exports . "code")
=C2=A0 =C2=A0>=C2=A0 =C2=A0 (:cache .=C2=A0 =C2=A0"no")
=C2=A0 =C2=A0>=C2=A0 =C2=A0 (:noweb . "no")
=C2=A0 =C2=A0>=C2=A0 =C2=A0 (:hlines . "no")
=C2=A0 =C2=A0>=C2=A0 =C2=A0 (:tangle . "no")))

=C2=A0 =C2=A0> (defalias 'org-babel-execute:matlab 'org-babel-ex= ecute:ipython)
=C2=A0 =C2=A0> (defalias 'org-babel-prep-session:matlab 'org-bab= el-prep-session:ipython)
=C2=A0 =C2=A0> (defalias 'org-babel-matlab-initiate-session 'org= -babel-ipython-initiate-session)
=C2=A0 =C2=A0> #+END_SRC


=C2=A0 =C2=A0> #+RESULTS:
=C2=A0 =C2=A0> : org-babel-matlab-initiate-session

=C2=A0 =C2=A0> To enable this:

=C2=A0 =C2=A0> #+BEGIN_SRC matlab :results output org drawer
=C2=A0 =C2=A0> x =3D [1, 2, 3, 4, 5];
=C2=A0 =C2=A0> fprintf('|%d', x)
=C2=A0 =C2=A0> #+END_SRC

=C2=A0 =C2=A0> #+RESULTS:
=C2=A0 =C2=A0> :RESULTS:
=C2=A0 =C2=A0> | 1 | 2 | 3 | 4 | 5 |
=C2=A0 =C2=A0> :END:

=C2=A0 =C2=A0> It is not much better output wise without the fprintf, bu= t that seems to
=C2=A0 =C2=A0> be a feature of Matlab's output. I think Eric is prob= ably right, you
=C2=A0 =C2=A0> will have use fprintf to get what you want.

=C2=A0 =C2=A0> I am not a big matlab user these days, so I do not have a= sense for how
=C2=A0 =C2=A0> usable the kernel is. It does run in a session, which is = a big
=C2=A0 =C2=A0> improvement over the other one I wrote.

=C2=A0 =C2=A0> Uwe Brauer writes:



--
John

---= --------------------------------
Professor John Kitchin=C2=A0
Doherty= Hall A207F
Department of Chemical Engineering
Carnegie Mellon Univer= sity
Pittsburgh, PA 15213
412-268-7803
--001a114b318ef4f66a054a753638--