[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] workflow, matlab+latex in org file
From: |
Uwe Brauer |
Subject: |
Re: [O] workflow, matlab+latex in org file |
Date: |
Fri, 10 Mar 2017 22:50:38 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) |
>>> "John" == John Kitchin <address@hidden> 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
- Re: [O] workflow, matlab+latex in org file, Eric S Fraga, 2017/03/10
- Re: [O] workflow, matlab+latex in org file, Uwe Brauer, 2017/03/10
- Re: [O] workflow, matlab+latex in org file, Uwe Brauer, 2017/03/11
- Re: [O] workflow, matlab+latex in org file, John Kitchin, 2017/03/11
- Re: [O] workflow, matlab+latex in org file, Uwe Brauer, 2017/03/11
- Re: [O] workflow, matlab+latex in org file, John Kitchin, 2017/03/11
- Re: [O] workflow, matlab+latex in org file, Uwe Brauer, 2017/03/11
- Re: [O] workflow, matlab+latex in org file, Uwe Brauer, 2017/03/11