I am new to octave and learning it.
Suppose I have a matrix X =
1 2
3 4
5 6
I want to access this matrix from second row, omitting the first row.
What is the syntax for it!?
I could delete the row by X(1,:) = [] which will change the original matrix,
How to access from the second row in octave?
To extract an entire row or column, use the colon : operator like this, octave#:#> X(1,:) This will extract the first row of the matrix X. In this notation, the : operator refers to all the elements in the specified row or column. To change some elements of a matrix, simply reassign their values.
Accessing the elements of the matrix : The elements of a matrix can be accessed by passing the location of the element in parentheses. In Octave, the indexing starts from 1.
To get a specific row of a matrix, specify the row number followed by a comma, in square brackets, after the matrix variable name. This expression returns the required row as a vector.
Use colon syntax. To return row 2 to the end use:
X(2:end, :)
See GNU Octave documentation for more indexing options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With