+

Addition operator.

Syntax

expr_1+expr_2

Operand

expr_1, expr_2
A pair of valid scalar, vector, matrix, string, or string array expressions.

Example

Expression Result
1 + 2 3
1 + {1, 2, 3} {2, 3, 4}
{1, 2, 3} + {4, 5, 6} {5, 7, 9}
2 + { {1, 2, 3}, {4, 5, 6} } { {3, 4, 5}, {6, 7, 8} }
{ {3, 4, 5}, {6, 7, 8} } + { {4, 6, 8}, {2, 4, 6} } { {7, 10, 13}, {8, 11, 14} }
"abc" + "def" "abcdef"
{"ghi", "jkl"} + "abc" {"ghiabc", "jklabc"}
"abc" + {"ghi", "jkl"} {"abcghi", "abcjkl"}
{"ab", "cd"} + {"ef", "gh"} {"abef", "cdgh"}

Comments

The addition operator adds expr_1 and expr_2.

If expr_1 and expr_2 are scalars, the result is the scalar sum of expr_1 and expr_2.

If expr_1 or expr_2 is a scalar and the other is a vector, the scalar is added to each element in the vector. The result is a vector with the same number of elements as the original vector.

If expr_1 or expr_2 is a scalar and the other is a matrix, the scalar is added to each element of the matrix. The result is a matrix with the same dimensions as the original matrix.

If expr_1 and expr_2 are vectors, the result is a vector containing the sums of the corresponding elements from each vector. Both vectors must have the same number of elements. The result contains the same number of elements as the two operands.

If expr_1 and expr_2 are matrices, the result is a matrix containing the sums of the corresponding element from each matrix. Both matrices must have the same dimensions. The result has the same dimensions as the two operands.

If expr_1 and expr_2 are strings, the result is a single string with the second expression appended to the first.

If expr_1 is a string and expr_2 is a string array, the string is appended to each element of the string array. The result is a string array with the same number of elements as the original string array.

If expr_1 is a string array and expr_2 is a string, each element of the string array is appended to the string to form a new array element. The result is a string array with the same number of elements as the original string array.

If expr_1 and expr_2 are string arrays, the result is a string array containing the elements of the second array appended to the corresponding elements of the first array. Both arrays must have the same number of elements. The result is a string array with the same number of elements as both of the two string arrays.