Vector in Octave is similar to the array in every aspect except the vector size is dynamic, which means its size can be increased however array does not allow such type of increment in its size.

**Types of Vectors**

- Row Vector
- Column Vector

**Row vectors** are created by enclosing the set of elements in square brackets, using space or comma to delimit the elements.

`% using space as the delimiter ` `RowVector1 = [1 2 3 4 5]; ` `disp(RowVector1); ` ` ` `% using comma as the delimiter ` `RowVector2 = [1, 2, 3, 4, 5]; ` `disp(RowVector2); ` |

*chevron_right*

*filter_none*

**Output :**

1 2 3 4 5 1 2 3 4 5

**Column vectors** are created by enclosing the set of elements in square brackets, using a semicolon to delimit the elements.

`ColumnVector = [1; 2; 3; 4; 5]; ` `disp(ColumnVector); ` |

*chevron_right*

*filter_none*

**Output :**

1 2 3 4 5

**Accessing Elements in a Vector in Octave GNU :** A vector element is accessed using the index of that element. The indexing starts from 1(not from 0). Language like C++, Java uses index from 0 to size-1, whereas in OCTAVE GNU index starts from 1 and ends at size; Also C++, java uses [] (Square Bracket) to access elements using index but in OCTAVE GNU parenthesis are used to access elements using the index.

`Vector = [10 20 30 40 50]; ` `for` `i = 1 : 5 ` ` ` `printf(` `"Element at Vector(%d) is %d\n"` `, i, Vector(i)); ` `endfor ` |

*chevron_right*

*filter_none*

**Output :**

Element at Vector(1) is 10 Element at Vector(2) is 20 Element at Vector(3) is 30 Element at Vector(4) is 40 Element at Vector(5) is 50

## Recommended Posts:

- How to take input in Octave GNU?
- Comments in Octave GNU
- Switch case statement in Octave GNU
- How to output in Octave GNU
- Strings in Octave GNU
- How to load and modify matrices and vectors in Octave?
- Basic Operations in Octave
- How to Perform Computational Operations in Octave?
- Loops (For and While) and Control Statements in Octave
- Octave - Basics of Plotting Data
- Difference Between MATLAB and Octave
- Difference Between MATLAB and Mathematica
- Difference Between MATLAB and Julia
- Features of C++

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.