Computers

Octave Multiplication Operator

Octave Multiplication Operator

In this tutorial, we will learn about the Octave Multiplication Operator with Examples. The multiplication operator in Octave is (*). The * operator is a binary operator that requires two operands for computation. The operands can be scalars or matrices.

Examples

Multiply scalars

If the operands are scalars, the multiplication operator multiplies the operands. Here in this example, x and y are scalar operands. We use the * operator to multiply and store the result in a variable called result.

>> x = 7;
>> y = 9;
>> result = x * y;
>> result

result = 63

 

Octave Multiplication Operator

Multiply 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 multiplication of the matrices.

>> x = [ 1 2 ; 3 4];

>> y = [ 5 6 ; 7 8];

>> result = x .* y ;

>> result

result =

5       12

21     32

Element wise multiplication matrices

—

Octave Tutorials

GNU Octave Tutorials on this website can be found at: