In this tutorial, we will learn the steps to Create a New Matrix using GNU Octave.
Create a New Matrix
We can create a new matrix or vector with square brackets. We can specify the matrix elements between . We can use a comma or a space to separate entries in a row, and a semicolon( ; ) or carriage return to separate the rows.
We can store the matrix in a variable so that we can refer to it later in the script.
To create a new matrix with 2 rows and 3 columns.
We can end the command with a semicolon(;) to tell Octave not to print the result of the command or the variable.
Octave also provides some in-built functions to create vectors. The rand(row, column) function creates a matrix with random values.
For example, to create a matric with 3 rows and 4 columns with random elements, we can use the following command:
By default, each element in the matrix will be set to a value between 0 and 1.
The other most used functions to create matrices are:
For example, the function zeros(2) creates a matrix with all elements as zero with two rows and two columns.
>> a = zeros(2)
The function ones(2) creates a matrix with all elements as one with two rows and two columns.
GNU Octave Tutorials on this website can be found at:
For more information on Octave, visit the official website: