27rohitb.github.io

Unit checking!

Following packages are used:

Attaching units to any quantity:

# METHOD 1: use '*u"<units>"'
a = 9.18*u"m/s^2"

# METHOD 2:
v0 = 5u"m/s"

Displaying unit

Normal print function will display them

Converting unit

uconvert(u"yr", t1)
# unconvert(<convert to>, <given param>)

Expanding constants to normal units:

h = 10*u"\hbar"
println(h)

Look at Dimensions:

print(typeof(h))

View in SI units:

print(upreferred(h))

NOTE Default value of upreferred function is SI units, but it can changed to CGS as follows:

using Unitful
Unitful.preferunits(u"cm,g,s"...)