Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline Davide Carpi  
#1 Posted : 09 July 2012 11:50:04(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,647
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
Hi all Good

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

Edited by user 26 July 2012 15:25:48(UTC)  | Reason: Not specified

File Attachment(s):
units.sm (24kb) downloaded 109 time(s).
units_examples.sm (45kb) downloaded 94 time(s).
Davide Carpi attached the following image(s):
units_examples.png
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
thanks 4 users thanked Davide Carpi for this useful post.
on 09/07/2012(UTC),  on 09/07/2012(UTC),  on 09/07/2012(UTC),  on 09/07/2012(UTC)

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline kilele  
#2 Posted : 10 July 2012 17:06:44(UTC)
kilele


Rank: Advanced Member

Groups: Registered
Joined: 30/03/2011(UTC)
Posts: 393

Was thanked: 132 time(s) in 113 post(s)
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/for...52_solving-equation.aspx
Offline Davide Carpi  
#3 Posted : 10 July 2012 19:07:46(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,647
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
Originally Posted by: kilele Go to Quoted Post
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/for...52_solving-equation.aspx


Hi,

happy to be useful Wink

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


regards,

w3b5urf3r

Edited by user 10 July 2012 23:09:22(UTC)  | Reason: Not specified

Davide Carpi attached the following image(s):
solve_units.PNG
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline Davide Carpi  
#4 Posted : 25 July 2012 00:32:19(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,647
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
Originally Posted by: kilele Go to Quoted Post
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/for...52_solving-equation.aspx


snippet updated!

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

see the attachment for the usage


regards,

w3b5urf3r

Edited by user 25 July 2012 00:34:20(UTC)  | Reason: Not specified

File Attachment(s):
units.sm (31kb) downloaded 72 time(s).
units_examples.sm (62kb) downloaded 65 time(s).
Davide Carpi attached the following image(s):
uSolve.PNG
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
thanks 2 users thanked Davide Carpi for this useful post.
on 25/07/2012(UTC),  on 25/07/2012(UTC)
Offline kilele  
#5 Posted : 25 July 2012 01:15:02(UTC)
kilele


Rank: Advanced Member

Groups: Registered
Joined: 30/03/2011(UTC)
Posts: 393

Was thanked: 132 time(s) in 113 post(s)
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 ?
Offline Davide Carpi  
#6 Posted : 25 July 2012 02:40:02(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,647
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
Hi kilele Good

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

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

- uSolve.2(#) 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

Edited by user 25 July 2012 02:43:02(UTC)  | Reason: Not specified

Davide Carpi attached the following image(s):
deflection.PNG
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline kilele  
#7 Posted : 25 July 2012 04:52:09(UTC)
kilele


Rank: Advanced Member

Groups: Registered
Joined: 30/03/2011(UTC)
Posts: 393

Was thanked: 132 time(s) in 113 post(s)
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

Edited by user 25 July 2012 04:56:33(UTC)  | Reason: Not specified

Offline Davide Carpi  
#8 Posted : 25 July 2012 14:15:10(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,647
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
Hi,

Originally Posted by: kilele Go to Quoted Post
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

Edited by user 18 September 2012 01:35:39(UTC)  | Reason: Not specified

Davide Carpi attached the following image(s):
magnitude.png
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.