simscape.Unit
Description
simscape.Unit
represents units of measure without an associated
value, and therefore lets you write MATLAB® functions that emulate the unit propagation behavior.
simscape.Unit
is an array of units, which means that it can represent
multiple units of measure at the same time. However, you can use only scalar
simscape.Unit
objects to specify units in simscape.Value
objects.
Creation
Syntax
Description
creates a unit.
Unit
= simscape.UnitUnit
is a 1x1 array of unit 1
.
creates a unit.
Unit
= simscape.Unit(1)Unit
is a 1x1 array of unit 1
.
converts Unit
= simscape.Unit(CHR
)CHR
to a unit. Unit
is a 1x1 unit array
that contains the unit obtained by parsing CHR
.
CHR
must be a valid unit expression, specified as a character
vector or string.
converts cell array Unit
= simscape.Unit(C
)C
to a unit array. Each element of
C
must be a character vector that represents a valid unit
expression. Unit
is the same size as C
.
converts string array Unit
= simscape.Unit(S
)S
to a unit array. Each element of
S
must be nonmissing and must represent a valid unit expression.
Unit
is the same size as S
.
Object Functions
commensurate | Check whether units are mutually commensurate |
computational | Determine computational unit for commensurate units |
convert | Convert numeric array from one unit into another |
You can also use the typical MATLAB array operations, including dimension queries, concatenation, indexing, and so
on. simscape.Unit
cannot be used to index into other array object. For more
information, see Working with simscape.Value and simscape.Unit Objects.
Examples
Limitations
Direct block parameterization is not supported, that is, you cannot use
simscape.Unit
objects directly to specify block parameters. You can use these objects only during programmatic model construction.You cannot use
simscape.Unit
objects to specify values with units or perform unit computations in Symbolic Math Toolbox™.MATLAB Coder™ does not support
simscape.Unit
objects.You can use MAT-files to save and load
simscape.Unit
objects. However, unit derivation is not saved with the units, so if asimscape.Unit
is saved with a unit and loaded in a subsequent MATLAB session where some part of the unit is not defined, then MATLAB issues a warning and the object results in an invalid variable.