check length of matrix (rows)