emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

To convert and simplify units in tables (was:LIterate programming with c


From: Ypo
Subject: To convert and simplify units in tables (was:LIterate programming with calc (help))
Date: Sun, 27 Nov 2022 20:19:42 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

Hi

I have found an alternative solution to this problem:

Is it possible to express in a calc block some basic operations with variables and non-predefined units?


For example, if you wanted to build a code block that calculates how much money costs

a land with an Area of 300x300 m^2 at a price of 1 $/m^2.


Would it be something like this?

#+begin_src calc
  a = 300 m
  b = 300 m
  Area = a*b
  cost = 1 ($/m^2)
  A*c

#+end_src


The alternative way I am trying is using an org-table. It is not literate programming, but it is a spreadsheet with units ;D

| $ | a = 300 m        |
| $ | b = 300 m        |
| _ | Area             |
|   | 90000 m^2        |
| $ | cost = 1 USD/m^2 |
| _ | Payment          |
|   | 90000 USD        |
#+TBLFM: $Area=$a*$b::$Payment=$Area*$cost

(Below "Area" cell it is the result of a*b, and below "Payment" cell it is the result of Area*cost)


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 = 10000 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

Below "cs" cell it appears 7.2... and this should be an adimensional number (no units). Is it possible to simplify those units?

I have tried with:

| $ | E = 2141404.05  kg/cm^2 |
| $ | s_lim = 275  N/mm^2     |
| $ | s_lim = 2800  kg/cm^2   |
| $ | W = 10000 kg            |
| $ | l = 65  cm              |
| $ | I = 25166  cm^4         |
| $ | Z = 1680  cm^3          |
| _ | s                       |
|   | 386.90476 kg / cm^2     |
| _ | cs                      |
|   | #ERROR                  |
#+TBLFM: $s=uconvert($W*$l/$Z,kg / cm^2)::$cs=uconvert($s_lim/$s, )

where uconvert is defined as:

(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?


Best regards



reply via email to

[Prev in Thread] Current Thread [Next in Thread]