simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

unit.md (1037B)


      1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
      2 
      3 # Function unit
      4 
      5 Create a unit. Depending on the passed arguments, the function
      6 will create and return a new math.Unit object.
      7 When a matrix is provided, all elements will be converted to units.
      8 
      9 
     10 ## Syntax
     11 
     12 ```js
     13 math.unit(unit : string)
     14 math.unit(value : number, unit : string)
     15 ```
     16 
     17 ### Parameters
     18 
     19 Parameter | Type | Description
     20 --------- | ---- | -----------
     21 `args` | * &#124; Array &#124; Matrix | A number and unit.
     22 
     23 ### Returns
     24 
     25 Type | Description
     26 ---- | -----------
     27 Unit &#124; Array &#124; Matrix | The created unit
     28 
     29 
     30 ## Examples
     31 
     32 ```js
     33 const a = math.unit(5, 'cm')    // returns Unit 50 mm
     34 const b = math.unit('23 kg')    // returns Unit 23 kg
     35 a.to('m')                       // returns Unit 0.05 m
     36 ```
     37 
     38 
     39 ## See also
     40 
     41 [bignumber](bignumber.md),
     42 [boolean](boolean.md),
     43 [complex](complex.md),
     44 [index](index.md),
     45 [matrix](matrix.md),
     46 [number](number.md),
     47 [string](string.md),
     48 [createUnit](createUnit.md)