Change language to:
Français - 日本語 - Português - Русский

Please note that the recommended version of Scilab is 2024.1.0. This page might be outdated.
See the recommended documentation of this function

Scilab Help >> Scilab > Scilab keywords > plus (+)

# plus (+)

Numerical addition. Text concatenation (gluing)

```X + Y
str1 + str2```

### Arguments

X,Y

scalars, vectors, matrices or hypermatrices of booleans, numbers, polynomials, or rationals. They may also be `syslin` lists.

str1, str2

two texts, vectors, matrices, or hypermatrices of texts.

### Description

For numeric operands, the addition has its usual meaning.

Adding booleans together or to numbers of integer, decimal or complex type performs the implicit conversions `%F => 0` and `%T => 1` before processing. The result has the type of the input numbers, or is decimal for booleans added together.

For two texts, `+` concatenates (glues) them together.

If an operand is an array and the other one is a scalar, the scalar is applied (added or glued) to each component of the array.

If an operand is the empty matrix `[]`, the result is `[]`.

The addition operator may be extended to other data types through overloading.

### Examples

```[1, 2] + 1
[] + 2
%s + 2
1/%s + %s
"con" + ["catenate" "crete" "sole"]```
```--> [1, 2] + 1
ans  =
2.   3.

--> [] + 2
ans  =
[]

--> %s + 2
ans  =
2 +s

--> 1/%s + %s
ans  =
2
1 + s
------
s

--> "con" + ["catenate" "crete" "sole"]
ans  =
!concatenate  concrete  console  !
```

With booleans:

```[%f %f %t %t] + [%f %t %f %t]
%f + [-1 0 2 %i]
%t + [-1 0 2 %i]```
```--> [%f %f %t %t] + [%f %t %f %t]
ans  =
0.   1.   1.   2.

--> %f + [-1 0 2 %i]
ans  =
-1.   0.   2.   i

--> %t + [-1 0 2 %i]
ans  =
0.   1.   3.   1. + i
```

 Version Description 6.0.0 `A + []` now returns `[]` instead of `A`