# How to find the number of rows and columns of a matrix in Octave

In this lesson I'll explain how to find the number of rows and columns of a matrix array in Octave.

I'll give you a practical example.

Create a 2x3 matrix with two rows and three columns.

>> M=[1 2 3;4 5 6]

M =

1 2 3

4 5 6

To get the number of rows and columns use the **size()** function

>> size(M)

The result is a list of values.

ans = 2 3

The first value is the number of rows in the matrix. The second value is the number of columns in the matrix.

This means that the matrix has 2 rows and 3 columns.

$$ M = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{pmatrix} $$