Array Operations

Operators

The basic unary and binary array operations all have an operator form:

OperatorEquivalent Function
+plus
-minus
.*times
./rdivide
.\ldivide
.^power

Notes

  • All of the array operations above are binary; their operands must satisfy Matlab Compatible Array Sizes. The operation is performed by first expanding both operands to a common size, then applying the operation element-by-element on equal indices

    • For example:

      >> a = [1 2 3]; b = [1 2 3]';
      >> a .* b % equivalent to repmat(a,3,1) .* repmat(b,1,3)
      ans =
          1     2     3
          2     4     6
          3     6     9
  • Addition and subtraction coincide for array and matrix operations, so there is no separate dotted form

  • A ./ B divides element-wise with A as the numerator and B as the denominator

  • A .\ B divides element-wise with A as the denominator and B as the numerator