Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2024.1.0 - English


plus (+)

Numerical addition. Text concatenation (gluing)

Syntax

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

See also

  • minus — (-) subtraction operator. Sign change
  • operators — scilab operator names
  • overloading — display, functions and operators overloading capabilities
  • oldEmptyBehaviour — Controls the operation+ and operation- behaviour for Scilab
  • mtlb_a — Matlab addition emulation function

History

VersionDescription
6.0.0 A + [] now returns [] instead of A
Report an issue
<< percent Scilab keywords quote >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon Jun 17 17:49:14 CEST 2024