Main Content

value

Return array of numeric values converted into specified unit

Since R2021b

Description

example

A = value(V,unit) returns an array of numeric values of the simscape.Value object, V, converted into the specified unit, unit, by applying the appropriate scaling factor. unit must be commensurate with the unit of V.

example

A = value(V,unit,conversiontype) lets you select whether to apply affine or linear conversion to thermal units. Affine conversion is the default.

example

A = value(V) strips the associated unit and returns the array of numeric values contained in simscape.Value object, V. This syntax is equivalent to A = value(V,unit(V)).

Examples

collapse all

Create a simscape.Value object in meters:

V = simscape.Value([1 10 5], 'm')
V = 

     1    10     5

    (m)

Get the object value in the unit of the object, that is, in meters:

 value(V)
ans =

    1    10     5

Get the object value in centimeters:

 value(V, 'cm')
ans =

         100        1000         500

Get the object value in inches:

 value(V, 'in')
ans =
   39.3701  393.7008  196.8504

Thermal units often require an affine conversion, that is, a conversion that performs both multiplication and addition. For more information, see About Affine Units. When you extract values from a simscape.Value object that has affine units, you can specify the desired conversion type.

Create a simscape.Value object in degrees Celsius:

T = simscape.Value(10, 'degC')
T = 

    10 (degC)

Get the object value in Kelvin by performing affine conversion:

 value(T, 'K', 'affine')
ans =

    283.1500

Tip

Affine conversion is the default, therefore value(T, 'K') also returns 283.1500.

Get the object value in Kelvin by performing linear conversion:

 value(T, 'K', 'linear')
ans =

    10

Input Arguments

collapse all

Array of numeric values with unit, specified as a simscape.Value object.

Example: 10 (m/s^2)

Physical unit expression, specified as a character vector, nonmissing string scalar, or a scalar simscape.Unit object. The string or character vector expression can consist of valid physical unit names, numbers, math operators, such as +, -, *, /, and ^, and parentheses to specify the order of operations. unit must be commensurate with the unit of V.

Example: 'mm/s^2'

Thermal units often require an affine conversion, that is, a conversion that performs both multiplication and addition. For more information, see About Affine Units. When you extract values from a simscape.Value object that has affine units, you can specify the type of conversion:

  • 'affine' — Perform unit conversion that uses both multiplication and addition.

  • 'linear' — Perform unit conversion by applying just the linear term.

Data Types: char | string

Output Arguments

collapse all

Array of numeric values extracted from the simscape.Value object by applying the specified unit conversion factor and returned as a scalar, vector, or matrix.

Data Types: double

Version History

Introduced in R2021b

expand all