Units snippet

Units snippet - 消息

#1 已发布: 2012/7/9 04:50:04
Davide Carpi

Davide Carpi

1,443个赞,共2,936个帖子。

组: 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.24 KiB)已下载 1701 次。
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 2012/7/9 06:03:00, sergio 2012/7/9 07:23:00, Oscar Campo 2012/7/9 11:15:00, Andrey Ivashov 2012/7/9 13:55:00
#2 已发布: 2012/7/10 10:06:44
kilele

kilele

134个赞,共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 已发布: 2012/7/10 12:07:46
Davide Carpi

Davide Carpi

1,443个赞,共2,936个帖子。

组: 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 已发布: 2012/7/24 17:32:19
Davide Carpi

Davide Carpi

1,443个赞,共2,936个帖子。

组: 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.2 KiB)已下载 1671 次。
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
2位用户喜欢此帖子
sergio 2012/7/25 04:08:00, Radovan Omorjan 2012/7/25 07:40:00
#5 已发布: 2012/7/24 18:15:02
kilele

kilele

134个赞,共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 已发布: 2012/7/24 19:40:02
Davide Carpi

Davide Carpi

1,443个赞,共2,936个帖子。

组: 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 已发布: 2012/7/24 21:52:09
kilele

kilele

134个赞,共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 已发布: 2012/7/25 07:15:10
Davide Carpi

Davide Carpi

1,443个赞,共2,936个帖子。

组: 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
  • 有新帖
  • 无新帖