Units Conversion Toolbox

版本 1.5.0.0 (105.9 KB) 作者: John McDermid
This toolbox attaches units to Matlab variables and enables unit conversion.
3.8K 次下载
更新时间 2012/1/25

查看许可证

编者注: This file was selected as MATLAB Central Pick of the Week

Have you ever needed to convert horse power to watts but can't remember the conversion factor? How many inches light travels in a microsecond? This toolbox is designed to make getting these answers much easier.

The "unit" statement attaches units to a variable. For example,
>> x=unit(2,'yards')

x =
1.8288 m

returns the answer in International (SI) units. If you would rather have you answer in feet it can be converted to feet by

>> convert(x,'feet')

ans =
6 feet

Variables created by the "unit" statement can operated on by these operators:

Unary plus, Unary minus, +,-,*,.*,/,\,./,.\,^,.^,',.'
and sqrt

Variables are also supported by triginometric,hyperbolic, and exponential functions and can be compared by

==, ~=, >, <, >=, and <=

Special plotting routines are available for plotting variables with units. These are:

plot, semilogx, semilogy, and loglog

The toolbox appears in the html help screens and has "GettingStarted', "User Guide", and function help screens.

Just down load the tool box to the directory of you choice and set the Matlab path to include this directory. To verify operation, type

>> unit('yards')

ans =
0.9144 m

If you get this result, you are all set!

引用格式

John McDermid (2024). Units Conversion Toolbox (https://www.mathworks.com/matlabcentral/fileexchange/29621-units-conversion-toolbox), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2010b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Numeric Types 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.5.0.0

This update corrects the addition and subtraction of dimensionless quantities (previously reported an error) and also corrects the definition of a weber.

1.4.0.0

I made an omission on the last submission and no file (or the old file) was attached. This is the correct file!

1.3.0.0

This update was submitted and approved but did not end up in Matlab Central. Instead, the old one was there.

1.1.0.0

This program has been updated to resolve a problem that appeared in R2011b.
R2011B used "Units" as a built in function in a toolbox and does not check to see if you have the toolbox before throwing an error. "Units" has been renamed to "unit".

1.0.0.0