unitconvert

Unit conversion function.

Syntax
output = unitconvert(input, units)
output = unitconvert(input, units, g)
Description

unitconvert takes the input value and uses to conversion specified as a string in units to provide the output value.

In the unit conversions including magnetic field units, g gives the g factor for the conversion. If it is omitted, the g factor of the free electron 2.0023... is used (see gfree).

input can be a vector of values. In this case, g can be a scalar or a vector of the same size as input.

Conversion Units

The following strings are supported for unit conversions:

'cm^-1->eV' 'cm^-1->K' 'cm^-1->mT' 'cm^-1->MHz'
'eV->cm^-1' 'eV->K' 'eV->mT' 'eV->MHz'
'K->cm^-1' 'K->eV' 'K->mT' 'K->MHz'
'mT->cm^-1' 'mT->eV' 'mT->K' 'mT->MHz'
'MHz->cm^-1' 'MHz->eV' 'MHz->K' 'MHz->mT'
Examples

An electron spin with a g factor of 2.1 with a resonance frequency of 8.7 GHz is in magnetic field of about 296 mT.

B = unitconvert(8.7e3,'MHz->mT',2.1)
B =
  295.9977
See also

mhz2mt, mt2mhz