Octave is especially designed for matrix computations including solving systems of linear equations, factoring matrices, etc. So, linear algebra including creating vectors and matrices and the linear algebraic operations is straightforward.
In this article, we will discuss how to create vectors and matrices and their linear algebraic operations.
Vectors
Build Row Vectors using “[ ]” (Square Brackets)
To create a 1 x 2 row vector, a
You use the “square bracket” with empty space, i.e., ‘ ’ between elements as
[element1 element2 element3 …]
Enter the following in Octave command window, and you will see the results.
>> a=[3 5]
a =
3 5
Build Row Vectors using “:” (Colon)
To create a 1 x 5 row vector, b from 1 to 5 with an increment of 1, i.e.,
You use
x = j:k
This creates a row vector “x” starting from “j” to “k” with the increment of 1. Enter the following in Matlab/Octave command window, and you will see the results.
>> b = 1:5
b =
1 2 3 4 5