Site icon TestingDocs.com

Octave Power Operator

Overview

In this tutorial, we will learn about Octave Power Operator
with Examples.

Octave Power Operator

We have two operators in Octave to compute the power.

x ^ y
x ** y

The result of the computation depends on the values of the operands x and y.

If both x and y are scalars then

x ^ y returns the result x raised to the power of y.

If x is scalar and y is a square matrix the result would be eigenvalue expansion.

Examples

^ Operator

Let’s look at a simple example.

>> x = 2;
>> y = 3;
>> result = x ^ y;
>> result

result = 8

The result is 2*2*2 = 8

** Operator

We can also use the ** operator.

>> x = 4;
>> y = 4;
>> result = x ** y;
>> result

result =  256

Element wise Power

To compute element-wise matrix power calculation, we can use the following operator.

x.^y

>> x = 2 ;
>> y = [2, 3; 3 , 5];
>> result = x.^ y

result =

                4            8
                8           32

 

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