Units snippet

Units snippet - Сообщения

#1 Опубликовано: 09.07.2012 04:50:04
Davide Carpi

Davide Carpi

1415 сообщений из 2872 понравились пользователям.

Группа: Moderator

Hi all

In this snippet there are several functions to work with units:

- Extracting Unit of Measurement
- Calculate Order of Magnitude
- Rounding
- Truncate
- Floor
- Ceiling


best regards,

w3b5urf3r


known limitations: because 0 in SMath have no units, so UoM() return 1 every time the argument is set to 0*anyPossibleUnit

snippet updated: see reply #4
units_examples.sm (44 КиБ) скачан 117 раз(а).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
4 пользователям понравился этот пост
Radovan Omorjan 09.07.2012 06:03:00, sergio 09.07.2012 07:23:00, Oscar Campo 09.07.2012 11:15:00, Andrey Ivashov 09.07.2012 13:55:00
#2 Опубликовано: 10.07.2012 10:06:44
kilele

kilele

133 сообщений из 397 понравились пользователям.

Группа: User

Thank you very much for these useful functions!!
Could be possible a function to remove units from an equation in order to apply Solve ?
please look at
http://en.smath.info/forum/yaf_postst652_solving-equation.aspx
#3 Опубликовано: 10.07.2012 12:07:46
Davide Carpi

Davide Carpi

1415 сообщений из 2872 понравились пользователям.

Группа: Moderator

Wrote

Thank you very much for these useful functions!!
Could be possible a function to remove units from an equation in order to apply Solve ?
please look at
http://en.smath.info/forum/yaf_postst652_solving-equation.aspx



Hi,

happy to be useful

Actually I think the simplest way it's to insert units inside the "expression" argument of solve() (see the attachment)


regards,

w3b5urf3r
solve_units.PNG
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#4 Опубликовано: 24.07.2012 17:32:19
Davide Carpi

Davide Carpi

1415 сообщений из 2872 понравились пользователям.

Группа: Moderator

Wrote

Thank you very much for these useful functions!!
Could be possible a function to remove units from an equation in order to apply Solve ?
please look at
http://en.smath.info/forum/yaf_postst652_solving-equation.aspx



snippet updated!

now there are [MATH]uSolve.2(#)[/MATH] and [MATH]uSolve.4(#)[/MATH] to reproduce [MATH]solve(2)[/MATH] and [MATH]solve(4)[/MATH] with units

see the attachment for the usage


regards,

w3b5urf3r
units_examples.sm (61 КиБ) скачан 86 раз(а).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
2 пользователям понравился этот пост
sergio 25.07.2012 04:08:00, Radovan Omorjan 25.07.2012 07:40:00
#5 Опубликовано: 24.07.2012 18:15:02
kilele

kilele

133 сообщений из 397 понравились пользователям.

Группа: User

Thank you sir for sharing your scripts, I didn't respond to your last post because I wanted to find the time to understand it well.
Is this usolve function able to deal with equations involving multiple units as in the example I cited above ?
#6 Опубликовано: 24.07.2012 19:40:02
Davide Carpi

Davide Carpi

1415 сообщений из 2872 понравились пользователям.

Группа: Moderator

Hi kilele

This snippet is a "little workaround" so have some limitations:

- [MATH]uSolve.2(#)[/MATH] and [MATH]uSolve.4(#)[/MATH] first argument must be a single-argument function

- [MATH]uSolve.2(#)[/MATH] need the third argument to know the unit of measurement of function argument


however, taking care of these limitations, inside the function you can use multiple units and the input and output units may be different (see the attachment, introduced in the new unit_examples.sm re-attached in the post above)


regards,

w3b5urf3r
deflection.PNG
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#7 Опубликовано: 24.07.2012 21:52:09
kilele

kilele

133 сообщений из 397 понравились пользователям.

Группа: User

wow I am very much obliged to you ^^ this is really useful
so the second parameter of usolve2 is also the desired output unit ? in my case the following samples always output meters:
usolve2(f(x),5 m, m)=9.96 m
usolve2(f(x),5 m, mm)=9.96 m
usolve2(f(x),5 m, cm)=9.96 m
#8 Опубликовано: 25.07.2012 07:15:10
Davide Carpi

Davide Carpi

1415 сообщений из 2872 понравились пользователям.

Группа: Moderator

Hi,

Wrote

so the second parameter of usolve2 is also the desired output unit ? in my case the following samples always output meters:
usolve2(f(x),5 m, m)=9.96 m
usolve2(f(x),5 m, mm)=9.96 m
usolve2(f(x),5 m, cm)=9.96 m



The third parameter provide only the kind of unit (mass,length,force,pressure,etc..), the desired output unit must be set in the right side, after the evaluation (see the attachment)


regards,

w3b5urf3r
magnitude.png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений