This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

symunit2str

Convert unit to character vector

Syntax

symunit2str(unit)
symunit2str(unit,toolbox)

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')

Introduced in R2017a