Main Content

symunit2str

Convert unit to character vector

Description

example

symunit2str(unit) converts the symbolic unit unit to a character vector.

example

symunit2str(unit,toolbox) converts the symbolic unit unit to a character vector representing units in the toolbox toolbox. The allowed values of toolbox are 'Aerospace', 'SimBiology', 'Simscape', or 'Simulink'.

Examples

Convert Unit to Character Vector

Convert the symbolic unit u.km to a character vector, where u = symunit.

u = symunit;
unitStr = symunit2str(u.km)
unitStr =
    'km'

Convert Unit for Specified Toolbox

Convert symbolic units to character vectors representing units in other toolboxes by specifying the toolbox name as the second argument to symunit2str. The allowed toolboxes are 'Aerospace', 'SimBiology', 'Simscape', or 'Simulink'. The unit must exist in the target toolbox to be valid.

Where u = symunit, convert u.km/(u.hour*u.s) to a character vector representing units from Aerospace Toolbox.

u = symunit;
unit = symunit2str(u.km/(u.hour*u.s),'Aerospace')
unit =
    'km/h-s'

Convert u.molecule/u.s to a character vector representing units from SimBiology®.

unit = symunit2str(u.molecule/u.s,'SimBiology')
unit =
    'molecule/second'

Convert u.gn/u.km to a character vector representing units from Simscape™.

unit = symunit2str(u.gn/u.km,'Simscape')
unit =
    'gee/km'

Convert u.rad/u.s to a character vector representing units from Simulink®.

unit = symunit2str(u.rad/u.s,'Simulink')
unit =
    'rad/s'

Input Arguments

collapse all

Symbolic unit to convert, specified as a symbolic unit.

Toolbox to represent unit in, specified as 'Aerospace', 'SimBiology', 'Simscape', or 'Simulink'.

Example: symunit2str(u.km/u.h,'Aerospace')

Version History

Introduced in R2017a