TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Octave

Octave Addition Operator

Overview

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

Octave Addition Operator

The addition operator in Octave is plus (+). The + operator is a binary operator. It requires two operands for the computation. The operands can be scalars or matrices.

Examples

Adding scalar operands

If the operands are scalars the addition operator adds the operands. 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

Octave Addition Operator

Adding matrices

If the operands are matrices, the number of rows and columns of the operands must agree or must 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

Element-wise matrix addition Octave

—

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

Related Posts

Octave Package List

Octave /

Install Octave Packages on Linux

Octave /

Octave User defined Function Example

octave command line linux

Octave /

Octave Command line on Ubuntu

Hello World in Octave

Octave /

Hello World in Octave

Octave /

Octave plot example of function y=x^2

‹ Octave Power Operator› Octave Subtraction Operator

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version