Code covered by the BSD License  

Highlights from
Unit Conversion

2.5

2.5 | 2 ratings Rate this file 2 Downloads (last 30 days) File Size: 1.72 KB File ID: #15046

Unit Conversion

by Anthony Kendall

 

18 May 2007 (Updated 10 Jan 2008)

A simple unit conversion function that is easily extended.

| Watch this File

File Information
Description

There are a few other unit conversion functions out there, but most are structured in a rather unwieldy format and require the use of extended switch...case blocks. This one uses a very simple structured array table to convert between any set of units that differ by a multiplicative offset and/or an additive factor.

The code is extremely lightweight, and fully vectorized.

The user must specify the input units and, optionally, the output units. If no output units are specified, than SI units are output (using degrees Celsius for temperature).

Only a limited set of conversions are included, but adding new ones should be fairly trivial. I encourage anyone who has questions, comments, or additions to write me at kendal30 [at] yahoo [dot] com.

Acknowledgements
This submission has inspired the following:
Unit Conversion Tools
MATLAB release MATLAB 7.4 (R2007a)
Other requirements This should work on any version of matlab that supports structured arrays.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
06 Sep 2007 l zq  
18 May 2008 chen le  
Please login to add a comment or rating.
Updates
10 Jan 2008

I have added a new group of units to the function.

Also, I wrote the function to be able to handle any combination of cell, numeric, and structured arrays (i.e. nested versions of cell/structured arrays).

Tag Activity for this File
Tag Applied By Date/Time
unit conversion simple Anthony Kendall 22 Oct 2008 09:13:05
unit conversion simple David 08 Apr 2010 15:06:16

Contact us at files@mathworks.com