Re: To convert and simplify units in tables

2022-12-12 Thread Fraga, Eric
On Sunday, 27 Nov 2022 at 20:19, Ypo wrote:
> The alternative way I am trying is using an org-table. It is not
> literate programming, but it is a spreadsheet with units ;D
> [...]
> Now, in a more practical case, I have some problems with units:
>
> | $ | E = 2141404.05  kg/cm^2  |
> | $ | s_lim = 275  N/mm^2  |
> | $ | s_lim = 2800  kg/cm^2|
> | $ | W = 1 kg |
> | $ | l = 65  cm   |
> | $ | I = 25166  cm^4  |
> | $ | Z = 1680  cm^3   |
> | _ | s|
> |   | 386.90476 kg cm / cm^3   |
> | _ | cs   |
> |   | 7.2369231 kg cm^3 / (cm^2 kg cm) |
>
> #+TBLFM: $s=$W*$l/$Z::$cs=$s_lim/$s

org tables do have support for units, based on Emacs Calc.  You need to
add the "u" option to the formulas for this support.  If I change your
formulas to:

#+TBLFM: $cs=$s_lim/$s;u::$s=$W*$l/$Z;u

everything seems to work just fine.  

-- 
: Eric S Fraga, with org release_9.6-14-g53814a in Emacs 30.0.50


Re: To convert and simplify units in tables (was:LIterate programming with calc (help))

2022-12-10 Thread ypuntot
Hi Ihor.
I'm null at elisp. Could you please refer to me a simple example of math 
operation and unit simplification in elisp?
Thanks :$

10 dic 2022 14:51:39 Ihor Radchenko :

> Ypo  writes:
> 
>> (defmath uconvert (v u)
>>   "Convert value V to compatible unit U."
>>   (math-convert-units v u))
>> 
>> 
>> But no luck, "cs" result is an ERROR. Is it feasible to get a value for
>> "cs" with no units?
> 
> Note that apart from Calc formula notation, you can use Elisp. That will
> avoid all the gotchas Calc has.
> 
> -- 
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 



Re: To convert and simplify units in tables (was:LIterate programming with calc (help))

2022-12-10 Thread Ihor Radchenko
Ypo  writes:

> (defmath uconvert (v u)
>    "Convert value V to compatible unit U."
>    (math-convert-units v u))
>
>
> But no luck, "cs" result is an ERROR. Is it feasible to get a value for 
> "cs" with no units?

Note that apart from Calc formula notation, you can use Elisp. That will
avoid all the gotchas Calc has.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at