symunit2str

Converts a symbolic unit expression into text.

Category: Symbolic Computations in MATLAB > Units of Measurement

Syntax

text = symunit2str(U)

Returns the unit expression U as a character vector.

Description

Units are normally displayed inside square brackets, as in [km]/[s]. symunit2str gives the plain notation, which is suited to labels, file names or messages, and which str2symunit can read back. A numeric factor stays in the text, so 5*u.m becomes '5*m'.

Input arguments

U
Symbolic unit expression or quantity.

Output arguments

text
Character vector without the square brackets, e.g. 'km/s'.

Example

Units as text

u = symunit;
symunit2str(u.km/u.s)
symunit2str(u.N)
symunit2str(5*u.m)
Output
ans = 'km/s'
ans = 'N'
ans = '5*m'

See also

str2symunit symunit char