Site icon TestingDocs.com

Octave Arithmetic Operators

Overview

In this tutorial, we will learn about Octave Arithmetic Operators. Arithmetic operators can be used for performing various mathematical operations on the variables. We can use these operators on both scalars and on vectors.

Octave Arithmetic Operators

An arithmetic operator is a symbol that Octave uses for arithmetic operations like addition, subtraction, multiplication, division, and exponentiation.

The arithmetic operators symbols are as follows:

Arithmetic Operation
Operator Symbol  Example
Addition

 

+ a + b
Subtraction a – b
Multiplication * a * b
Left Division

Right Division

\

/  

a / b
Power/Exponentiation **  or ^ a ** b or a ^b

Example

Let’s compute the sum of 10 and 25.

In this example, we will declare two scalar variables. Add the variables with the addition operator and print the result.

a = 10;

b = 25;

result = a + b ;

Screenshot

 

Element wise operations on Vectors

Arithmetic Operation
Operator Symbol  Example
Addition

 

.+ a .+ b
Subtraction .- a .- b
Multiplication .* a .* b
Division ./ a ./ b
Power .**  or .^ a .** b

Octave Tutorials

GNU Octave Tutorials on this website can be found at:

https://www.testingdocs.com/octave-tutorial/

For more information on Octave, visit the official website:

https://www.gnu.org/software/octave/index

Exit mobile version