how to get the number of rows of a matrix in matlab code example Example: matlab count elements in matrix A = [1 2 3; 4 5 6] n = numel(A)