uplus
Unary plus: returns its argument, with the numeric conversion of an operation.
Category: Language Fundamentals > Operators and Elementary Operations
Syntax
B = uplus(A)
Returns A. Same as +A.
Description
Numeric values pass through untouched. The one visible effect is the class conversion: +true is the double 1 and +'a' is 97, which is a short way to turn logicals or characters into numbers.
Classes can define uplus to give the unary + a meaning of their own.
Input arguments
A- Numeric, logical or char array.
Output arguments
B- Same values as
A. Logical and char inputs are converted to double.
Example
uplus([1 -2 3])
class(+true)
+'a'
Output
ans = 1×3
1 -2 3
ans = 'double'
ans = 97