emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Uwe Brauer <oub@mat.ucm.es>
To: John Kitchin <jkitchin@andrew.cmu.edu>
Cc: Uwe Brauer <oub@mat.ucm.es>, emacs-orgmode@gnu.org
Subject: Re: workflow, matlab+latex in org file
Date: Fri, 10 Mar 2017 16:08:45 +0000	[thread overview]
Message-ID: <87pohpcdwy.fsf@mat.ucm.es> (raw)
In-Reply-To: m2d1mk5fur.fsf@Johns-MacBook-Air.local

>>> "John" == John Kitchin <jkitchin@andrew.cmu.edu> writes:

Hi John,

Quite some time ago you send me this code of yours. It somehow
disappeared in my mail and only by now I tried it out, great, really 

Only one  question
I copied your code in a org file, executed the src sections and
obtained:


   > #+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

   > #+RESULTS: 
   > #+BEGIN_LaTeX

   > \left(\begin{array}{cc} {\left(\left(e + p\right)\, R^2 +
   > e\right)}^{\frac{g}{2} - \frac{3}{2}}\, \left(R^2 + 1\right)\,
   > \left(\frac{g}{2} - \frac{1}{2}\right) & R^2\, {\left(\left(e +
   > p\right)\, R^2 + e\right)}^{\frac{g}{2} - \frac{3}{2}}\,
   > \left(\frac{g}{2} - \frac{1}{2}\right)\\ \frac{R\, \sqrt{R^2 +
   > 1}}{\left(e + p\right)\, R^2 + e} - \frac{R\, {\left(R^2 +
   > 1\right)}^{\frac{3}{2}}\, \left(e + p\right)}{{\left(\left(e +
   > p\right)\, R^2 + e\right)}^2} & \frac{R\, \sqrt{R^2 + 1}}{\left(e +
   > p\right)\, R^2 + e} - \frac{R^3\, \sqrt{R^2 + 1}\, \left(e +
   > p\right)}{{\left(\left(e + p\right)\, R^2 + e\right)}^2}
   > \end{array}\right)
   > #+END_LaTeX

How do I suppose to continue now? Because if I  export this to a latex
file the latex equations are not exported! I admit that I only use org
files this way export them to latex and continue working.

What do I miss?

Thanks

Uwe

Your mail:

>You might consider the alternative, no-frills approach below. I defined
>a new execute function that strips the header and >> out of the output.
>It won't support any kind of session or header variables, but if you
>don't use those it might work for you.
>
>#+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
>
>#+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
>
>#+RESULTS: 
>#+BEGIN_LaTeX
>
>\left(\begin{array}{cc} {\left(\left(e + p\right)\, R^2 +
>e\right)}^{\frac{g}{2} - \frac{3}{2}}\, \left(R^2 + 1\right)\,
>\left(\frac{g}{2} - \frac{1}{2}\right) & R^2\, {\left(\left(e +
>p\right)\, R^2 + e\right)}^{\frac{g}{2} - \frac{3}{2}}\,
>\left(\frac{g}{2} - \frac{1}{2}\right)\\ \frac{R\, \sqrt{R^2 +
>1}}{\left(e + p\right)\, R^2 + e} - \frac{R\, {\left(R^2 +
>1\right)}^{\frac{3}{2}}\, \left(e + p\right)}{{\left(\left(e +
>p\right)\, R^2 + e\right)}^2} & \frac{R\, \sqrt{R^2 + 1}}{\left(e +
>p\right)\, R^2 + e} - \frac{R^3\, \sqrt{R^2 + 1}\, \left(e +
>p\right)}{{\left(\left(e + p\right)\, R^2 + e\right)}^2}
>\end{array}\right)
>#+END_LaTeX
>
>
>
>Uwe Brauer writes:
>
>[+]
>>>>> "John" == John Kitchin <jkitchin@andrew.cmu.edu> writes:
>>
>>    > Here is an example using sympy. I think you will have to wrap the matlab
>>    > output in $$ yourself if that is what you want.
>>
>> Right. Using your example I obtain:
>> ,----
>> | 
>> | 
>> |                             < M A T L A B (R) >
>> |                   Copyright 1984-2010 The MathWorks, Inc.
>> |                 Version 7.10.0.499 (R2010a) 32-bit (glnx86)
>> |                               February 5, 2010
>> | 
>> |  
>> |   To get started, type one of these: helpwin, helpdesk, or demo.
>> |   For product information, visit www.mathworks.com.
>> |  
>> | >> >> >> >> >> >> 
>> | ltxjac =
>> | 
>> | \left(\begin{array}{cc} {\left(\left(e + p\right)\, R^2 +
>> | e\right)}^{\frac{g}{2} - \frac{3}{2}}\, \left(R^2 + 1\right)\,
>> | \left(\frac{g}{2} - \frac{1}{2}\right) & R^2\, {\left(\left(e +
>> | p\right)\, R^2 + e\right)}^{\frac{g}{2} - \frac{3}{2}}\,
>> | \left(\frac{g}{2} - \frac{1}{2}\right)\\ \frac{R\, \sqrt{R^2 +
>> | 1}}{\left(e + p\right)\, R^2 + e} - \frac{R\, {\left(R^2 +
>> | 1\right)}^{\frac{3}{2}}\, \left(e + p\right)}{{\left(\left(e +
>> | p\right)\, R^2 + e\right)}^2} & \frac{R\, \sqrt{R^2 + 1}}{\left(e
>> | + p\right)\, R^2 + e} - \frac{R^3\, \sqrt{R^2 + 1}\, \left(e +
>> | p\right)}{{\left(\left(e + p\right)\, R^2 + e\right)}^2}
>> | \end{array}\right)
>> | 
>> | >>
>> `----
>>
>> That is not perfect but much better than the original solutions, thanks
>>
>> Uwe 
>
>
>-- 
>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
>

  parent reply	other threads:[~2017-03-10 16:08 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 [this message]
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
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=87pohpcdwy.fsf@mat.ucm.es \
    --to=oub@mat.ucm.es \
    --cc=emacs-orgmode@gnu.org \
    --cc=jkitchin@andrew.cmu.edu \
    /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).