MATLAB: Count the number of non-zero elements of a column/row of a 2D-Matrix

matrix

Hello everyone,
I have a 2D Matrix and I want to make Matlab count the number of non-zero Elements within one row, is there a straightforward way to do this? Many thanks

Best Answer

sum(X(row_number,:)~=0)