From mboxrd@z Thu Jan 1 00:00:00 1970 From: Uwe Brauer Subject: Re: workflow, matlab+latex in org file Date: Fri, 10 Mar 2017 22:50:38 +0000 Message-ID: <87a88szqyp.fsf@mat.ucm.es> References: <8760sc8ids.fsf@mat.ucm.es> <87shvg6z9i.fsf@mat.ucm.es> <87pohpcdwy.fsf@mat.ucm.es> <71b17ad2-04a9-c5fe-e431-7bd5e7804949@gmail.com> <87h930al52.fsf@mat.ucm.es> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cmTN9-0002rX-D5 for emacs-orgmode@gnu.org; Fri, 10 Mar 2017 17:50:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cmTN6-0005t1-57 for emacs-orgmode@gnu.org; Fri, 10 Mar 2017 17:50:55 -0500 Received: from [195.159.176.226] (port=42109 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cmTN5-0005sP-NR for emacs-orgmode@gnu.org; Fri, 10 Mar 2017 17:50:51 -0500 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cmTMt-00088a-GF for emacs-orgmode@gnu.org; Fri, 10 Mar 2017 23:50:39 +0100 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 >>> "John" == John Kitchin writes: > I get the right wrapper around the results block in the org-file. I did > have to add :exports results > to the header to get it to export though. Thanks ok the whole message you sent me I can now copy into a org file and export it to latex, very nice. However I just realized that I don't understand the logic of what you sent to me. So it looks like #+BEGIN_SRC emacs-lisp (defun org-babel-execute:matlab (body params) (interactive "P") (let* ((current-file (buffer-file-name)) (code (org-element-property :value (org-element-context))) (result-params (cdr (assoc :result-params params))) m-file md5-hash) (with-temp-buffer (insert code) (setq md5-hash (md5 (buffer-string)) mbuffer (format "*m-%s*" md5-hash) m-file (format "m-%s.m" md5-hash))) ;; create the file to run (with-temp-file m-file (insert code)) (let ((results (shell-command-to-string (concat "/Applications/MATLAB_R2013a.app/bin/matlab " "-nodesktop -nojvm -nosplash -nodisplay <" m-file)))) (delete-file m-file) (when results ;; strip out >> (setq results (replace-regexp-in-string ">> " "" results)) ;; remove first 10 lines that are the header. (setq results (mapconcat 'identity (nthcdr 10 (split-string results "\n")) "\n"))) (org-babel-result-cond result-params results)))) #+END_SRC That lisp function uses a m-file, but which one? When I run the lisp code in my org file (changing the path to my matlab installations path) I obtain #+RESULTS: : org-babel-execute:matlab But not what you have sent to me and I copied below namely #+begin_src matlab :results output latex clear all; syms e p R g w K K2; phi=[(e + (e+p)*R^2)^((g-1)/2);((e+p)*R*sqrt(1+R^2))/(e+(e+p)*R^2)]; jac=jacobian(phi,[e,p]); ltxjac=latex(jac); disp(ltxjac) #+end_src which I presume is your output of the lisp function? I am sorry but I am more confused than ever. I even see that I cannot (after I have executed your lisp function) execute anymore the following #+begin_src matlab :results output t=[-3 -2 1 4 6] y=[2 0 3 1 4] cs = spline(t,[0 y 0 ]) [b,c,l,k,d]= unmkpp(cs) #+end_src I tested it several times. I restart emacs open an org mode with the above matlab instructions and I can execute matlab. Then I execute your lisp code and I cannot run matlab anymore in an org buffer. What is wrong here? Uwe