Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing from 2nd row of the matrix in octave?

Tags:

octave

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?

like image 615
sat Avatar asked Sep 30 '12 17:09

sat


People also ask

How do I extract a row from a matrix 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.

How do you access elements in a matrix in octave?

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.

How do I extract a row from a matrix in R?

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.


1 Answers

Use colon syntax. To return row 2 to the end use:

X(2:end, :)

See GNU Octave documentation for more indexing options.

like image 116
Thor Avatar answered Oct 19 '22 00:10

Thor