Physical Units Toolbox

Version 5.0 (86.2 KB) by Sky Sartorius
Enables operations using hundreds of supported physical units of measurement and physical constants.
Updated 28 Feb 2024

Editor's Note: This file was selected as MATLAB Central Pick of the Week

If the Physical Units Toolbox is on your MATLAB path, there is nothing to initialize, import, add to your workspace, or pass to functions - simply multiply/divide by u.(unitName) to attach physical units to a variable. For example, to define a speed using a supported unit: carSpeed = 100 * u.kph. Or, define a speed with an unsupported unit as a combination of supported units: snailSpeed = 20 * u.m/u.week.

Variables with physical units attached are of the class DimVar ("dimenensioned variable"). Math operations performed on dimensioned variables will automatically perform dimensional analysis and can create new units or cancel units and return a normal variable.

On a global or per-project basis, you can customize to use the base unit system of your choice (e.g. ft-lb-s instead of the SI m-kg-s), as well as customize preferred display units. Display units for any given variable can also be customized. Variables will display in the command window or plot, etc. in terms of those units.

Most common Matlab functions will work with physical units, including many types of plots (with added axis labels).

Cite As

Sky Sartorius (2024). Physical Units Toolbox (, GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2021a
Compatible with R2016b and later releases
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Versions that use the GitHub default branch cannot be downloaded

Version Published Release Notes

Constants updates for the 2019 redefinition of SI base units.
Many derived constants updated with defining equations.


Axis labels for plots now use the custom display units associated with the arguments.

Recent update changed output syntax of displayparser method, so in the unlikely case that you use that (mostly internal) utility method in your code, you may have backward-compatibility issues, hence incrementing the version number.

Per-variable custom display units and other updates.

simplified, cleaner, faster, easier-to-maintain scheme (not back-compatible)

Added many units to mirror and
Added several constants from
Added property validator overloaded methods.

toolbox, help text.
Git. More base units. Better, hopefully clearer usage. More methods supported. Updated documentation to help the learning curve.

New str2u and surf methods. A few more units added.
Much more emphasis on using the u.m classdef, with documentation updated to reflect.

added sort method

mm-g-s common system added.

upload error

Added atan2, plot3, cat, plus other minor tweaks.

Plot method updated for R2015b, added isfinite and validateattributes methods, added u classdef functionality.

Preferred display units, updated documentation, some new methods.

Fixed error with Rankine.

Class name change!
Methods added: disp, num2str, cumtrapz, numel, isempty, reshape.
Plot method with auto-labeling axes with units.
A few more units added.

New, simpler, and fuller-functioning methods.

Added ability to switch base unit systems; added many more units; added 'dummy' unitsOf and u2num functions to keep from crashing when calling with non-DimensionedVariable arguments (addresses user concern)

added pressure, angle, and angular velocity units; added static method for working with string representations of units.

added features to unitslist method

Improved unitslist; added kp force unit.

Added new static method 'unitslist' that makes it easy to drastically speed up code developed using the class.

Fixed bug in displaying units with no numerator

New display method looks much better (in response to comments on rob's original post); new classdef structure

new subsasgn method; new html documentation; reworked help blocks; other updates

Documentation and examples; added functionality to u2num; added meshgrid function

added some units

added many units and did a lot of checking an updating so that more units meet their exact definitions

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.