units(varargin)

版本 1.0.0.0 (6.5 KB) 作者: Nikolay
Consistent conversion of physical units
277.0 次下载
更新时间 2016/1/17

查看许可证

input: x1 - initial data (scalar, vector, matrix)
s1 - string with initial units ('m/s','ohm*m','kJ/cm^3' etc)
s2 - string with target units
output: x2 - converted data
when output is empty, result is printed in command window.
feel free to expand list of available units by changing 'units' variable, where:
1st column: unit symbol
2nd column: 'MLTQ' based dimensions
3rd column: conversion factor
Symbolic Math Toolbox is required.
Examples:
units(1,'kN/mm^2','MPa') -> 1 kN/mm^2 = 1000 MPa
units(5*50,'mA^2*ohm','mW') -> 250 mA^2*ohm = 0.25 mW
units([1 10 100],'Mega*eV','micro*erg') -> 1 Mega*eV = 1.60218 micro*erg
10 Mega*eV = 16.0218 micro*erg
100 Mega*eV = 160.218 micro*erg

引用格式

Nikolay (2024). units(varargin) (https://www.mathworks.com/matlabcentral/fileexchange/54658-units-varargin), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2014b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Physics 的更多信息
标签 添加标签
致谢

参考作品: units.m

Community Treasure Hunt

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

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

cover picture
new input combinations are possible:

units(s1,s2) equivalent to units(1,s1,s2)
units(x1,s1) defines s2 as closest possible si-unit: s1='km/hour' -> s2='m/s', s1='kN*km/s' -> s2='J', etc.
units(s1) equivalent to units(1,s1)