How to extract a row from a matrix in Matlab and Octave
To extract a row from a matrix in Matlab and Octave, type the row number (n) and colon symbol (:) instead of the column number.
M(n,:)
This command extracts the nth row from the array.
Example
Define a matrix 2x3
X = [1 2 1 ; 3 1 1]
The matrix has this structure
1 2 1
3 1 1
To extract the first row type
X(1,:)
The command extracts the first row
1 2 1
To extract the second row type
X(2,:)
The command extracts the second row
3 1 1
https://how.okpedia.org/en/matlab/how-to-extract-a-row-from-a-matrix-in-matlab-and-octave
Report an error or share a suggestion to enhance this page