converts between different units, and checks that their dimensions are consistent
units may be compounds of other units (e.g. Newton-meters or meters/second)
units may have powers (e.g. meter^3 or m/s2)
units may have scaling prefixes (e.g. milimeters or kW)
unit('m','s') %causes error because wrong dimensions
Christopher Pedersen (2023). unit(varargin) (https://www.mathworks.com/matlabcentral/fileexchange/46045-unit-varargin), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!
Bug fixed: negative prefixes became positive (e.g. mm became 1E3 m rather than 1E-3m).
Added handling of nondimensional units.
added: allows nondimensional units
added 'detail' option that shows how each term of each unit is parsed
'verb' option gives additional reporting at each step (scale and power)
Corrected unit pound (weight) - was missing the last digit
Added definitions of Calorie and FoodCalorie
Added additional units (lightSpeed, horsepower, etc).
Fixed misspelling of unit "celsius"
Added ability to use custom units.
Added absolute temperature conversion.
New: allows a single input instead of two. Does not perform a conversion, instead just reports that one unit.