nmovshov/physunits

版本 1.5.0.0 (47.4 KB) 作者: Naor Movshovitz
Dimensioned variables with enforced dimensional consistency
1.2K 次下载
更新时间 2023/11/10

The `physunits` toolbox is an attempt to confer "dimensional awareness" to the
MATLAB environment. The motivation and a suggested algorithm are explained in:
Petty, G.W., 2001. Automated computation and consistency checking of physical
dimensions and units in scientific programs. _Software: Practice and Experience_,
31(11), pp.1067-1076. The author also made available for download a FORTRAN90
module that implements this idea in the FORTRAN language. The module and paper can
be downloaded from http://rain.aos.wisc.edu/~gpetty/physunits.html. The
`physunits` toolbox is based on that module and expands it while trying to adhere
consistently to MATLAB standards and practices (_from 2006_).
The `physunits` toolbox works by defining the `preal` data type and overloaded
functions to support it. A variable of type `preal` represents a physical
quantity. It has two _private_ fields: 'value' - the numerical value, which must
be a numeric type with zero imaginary part, and 'units' - a vector of 7 numbers,
representing the physical dimensions associated with 'value'. The format for the
'units' vector is [length, mass, time, temperature, electric current, amount of
matter, illumination, luminous intensity]. But these details are never needed by
the user, who defines his or her variables via an interface structure. The
interface structure contains predefined variables of type `preal`, representing
the most useful SI units as well as many other units, derived units, constants of
nature, parameters, etc. Get this structure by calling the `setUnits` function.
Create your own dimensioned variables by multiplying a number with an existing
`preal` variable.

See the HTML documentation for more details and examples.

### Setup

The physunits toolbox is implemented as an old-style (pre-2008) MATLAB class. In
this style MATLAB classes are defined by a directory of the class name preceded by
a `@` sign. The `@preal` directory contains the `preal` class definition and
methods. **To use the `preal` class, the directory immediately above `@preal` must
be on the MATLAB search path.**

引用格式

Naor Movshovitz (2024). nmovshov/physunits (https://github.com/nmovshov/physunits), GitHub. 检索时间: .

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

Community Treasure Hunt

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

Start Hunting!

无法下载基于 GitHub 默认分支的版本

版本 已发布 发行说明
1.5.0.0

Moving the submission to GitHub for easier maintenance

1.4.0.0

Adding an overloaded cumsum function.

1.3.0.0

I modified the < and <= operators to avoid dimension checking in the special case where the second argument has value zero. The only reason is to allow the common usage of
>> validateattributes(d, {'numeric'}, {'positive'})

1.2.0.0

Added setFUnits.m to create a "fake units" structure with only type double for deployment to users who do not wish to install the toolbox. Deployment usually involves a single line (single character really) change to code.
Update documentation.

1.0.0.0

Added a couple of overloaded functions
Fixed a dead link in documentation

要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库
要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库