Octave Addition Operator [ 2024 ]
Octave Addition Operator
In this tutorial, you will learn about the Octave addition operator with Examples. The addition operator in Octave is plus (+). The + operator is a binary operator that requires two operands for computation. The operands can be scalars or matrices.
Examples
Adding scalar operands
If the operands are scalars, the addition operator adds them. Here, in this example, x and y are scalar operands. We use the + operator to add and store the result in a variable called result.
>> x = 7;
>> y = 9;
>> result = x + y;
>> result
result = 16
Adding matrices
If the operands are matrices, the number of rows and columns must agree or be broadcastable.
We can use the .+ operator for the element-wise addition of the matrices.
>> x = [ 1 2 ; 3 4];
>> y = [ 5 6 ; 7 8];
>> result = x .+ y ;
>> resultÂ
result =Â
       6     8
      10   12
Octave Tutorials
GNU Octave Tutorials on this website can be found at:
For more information on Octave, visit the official website: