File Exchange

image thumbnail

Unit Conversion Tools

version 1.0 (40.4 KB) by

Command line, GUI, & Simulink block to convert physical units

8 Downloads

Updated

View License

Command line, GUI, & Simulink block to convert physical units. It is hoped that relationships between units are specified in an easy to extend manner.
unit_conversion is an m-script that allows one to convert physical units from the command line or a script. It can also provide lists of available transformations.

unit_conversion_gui is a simple graphical interface to unit_conversion.

lib_unit_conversion is a Simulink library block that uses unit_conversion to determine appropriate gains & offsets.

Comments and Ratings (3)

Turner

Turner (view profile)

The unit_conversion for Fahrenheit is incorrect!

Tried: unit_conversion(0, 'degK','degF')=-255.3722
Should be: unit_conversion(0, 'degK','degF')=−459.67
Tried: unit_conversion(0,'degC','degF')=236.2978
Shuld be: unit_conversion(0,'degC','degF')=32

Also added in two more units and included 'in' aka 'inch' as follows :
'unit',{{'mrad','mradian','mil'}},... %T.J. Modified
    'isSI',[0,0,0],...
    'gain',.001,...
    'bias',0,...
    'inv',false),...
    struct(...

'unit',{{'moa','MOA'}},... %T.J. Modified
    'isSI',[0,0],...
    'gain',6283/60/360,...
    'bias',0,...
    'inv',false),...

'unit',{{'inch','in'}},...
    'isSI',[0,0],...
    'gain',0.0254,...
    'bias',0,...
    'inv',false),...
    struct(...

% Finally fixed Fahrenheit with following code:
'unit',{{'Fahrenheit','degF'}},...
    'isSI',[0,0],...
    'gain',5/9,... % kelvin = 5/9 * ( degF - 32 ) + 273.15 = 5/9 * degF - 5/9 * 32 + 273.15
    'bias',459.67,... %T.J. modified, %orginal (5/9)*(-32)+273.15
    'inv',false),...
    struct(...

Ruoyu Cheng

Please bear me with one more comment. It will be very helpful if the authors can provide a help file (.pdf) listing the names or abbreviations of the units involved in this program. Thanks.

Ruoyu Cheng

It is a good program to handle the conversion between different unit systems. The authors' may notice that there is a small mistake in the mass unit conversion, where the "kilogram" was supposed to be the common unit instead of "gram".
Thanks, really good work!

Updates

1.0

Just going through the update process.

MATLAB Release
MATLAB 7.4 (R2007a)
Acknowledgements

Inspired by: Unit Conversion, Units (updated), CHANGEUNIT, Unit Conversion

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video