[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Unit conversions and symbolic mathematics with Babel
From: |
H. Dieter Wilhelm |
Subject: |
Re: [O] Unit conversions and symbolic mathematics with Babel |
Date: |
Thu, 04 Sep 2014 09:17:13 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.93 (gnu/linux) |
address@hidden (H. Dieter Wilhelm) writes:
> Hello Org,
>
> for some engineering most often I need estimations with unit
> conversions, Emacs Calc is perfect for this.
>
> When it comes to reporting and documentation I'd like to do it with
> org-mode, of course. For numerical stuff and visualisation purposes I'm
> using already R and TikZ. But for unit conversions and symbolic maths
> I'm in a bind when trying to do this with free programs.
>
> - R :: Do you have experience with a units packages under the R-project?
> What I've seen so far is not so reassuring...
>
> - Maxima :: I think there is a nice and intuitive units package for
> maxima. But this would mean learning an additional tool and mentally
> switching between both within one document.
>
> - Calc :: I'd prefer to do it with Calc but the Babel interface is
> (yet?) restricted
>
> For example, I can define functions and do some unit conversions:
>
> #+BEGIN_SRC emacs-lisp
> (defmath cvun(a b)
> (math-convert-units a b))
> #+END_SRC
>
> #+RESULTS:
> : calcFunc-cvun
>
> #+BEGIN_SRC calc :var L1 = "5 mm"
> cvun( L1, m)
> #+END_SRC
>
> #+RESULTS:
> : 5e-3 m
>
> But what is missing is to assign variables within a source block
>
> #+BEGIN_SRC calc :var L1 = "5 mm"
> L2 := cvun( L1, m)
> #+END_SRC
>
> Unfortunately this is not working. Do you have an idea how to
> implement this?
For your information: Jay Belanger found a workaround
#+BEGIN_SRC emacs-lisp
(defmath sett(a b) ; or any other name not identical to the applied lisp
functions
(set (nth 2 a) b))
#+END_SRC
#+RESULTS:
: calcFunc-sett
#+BEGIN_SRC calc :var L1 = 3
sett( L2, 3.14)
L2 - L1
#+END_SRC
#+RESULTS:
: 0.14
--
Dieter
> - Are you using (better) alternatives?
>
> Thanks for your insights
>
> Dieter
--
Best wishes
H. Dieter Wilhelm
Darmstadt, Germany