Define new unit
Load the collection of symbolic units by using
Find information on the predefined unit
u.c_0 for the speed
u = symunit; unitInfo(u.c_0)
speed of light in vacuum - a physical unit of velocity. Get all units for measuring 'Velocity' by calling unitInfo('Velocity').
Show that the exact value of the speed of light in SI is
299792458 metres per second.
c = unitConvert(u.c_0,'SI')
c = 299792458*([m]/[s])
Define the new unit
speedOfLightApprox for the approximate
value of the speed of light as
3e8 meters per second.
u = symunit; c = newUnit('speedOfLightApprox',3e8*u.m/u.s)
c = [speedOfLightApprox]
Alternatively, you can specify the unit by using
Define the equation E = mc2 using the new unit.
syms mass m = mass*u.kg; E = m*c^2
E = mass*[kg]*[speedOfLightApprox]^2
E in terms of meters per second.
E = rewrite(E,u.m/u.s)
E = 90000000000000000*mass*(([kg]*[m]^2)/[s]^2)
Since the standard unit of energy is the joule, rewrite
E in terms of
E = rewrite(E,u.Joule)
E = 90000000000000000*mass*[J]
name— Name of new unit
Name of the new unit, specified as a character vector or string. You cannot redefine a predefined unit or any of its alternate names.
definition— Definition of new unit
Definition of the new unit, specified as a symbolic expression of units. The new unit must be
defined in terms of existing symbolic units. For example,
symunit, defines workday as a unit representing 8