MATLAB: Check to find if a row has an element occuring more than once

element occurring more than a specified numberMATLAB

I need to find if a row has more than one occurence of 1s. I am expecting a response return like true or false. Sample row matrix is below:
0 0 1 1 0 0

Best Answer

  • A = [0 0 1 1 0 0; 0 0 0 0 0 1; 1 1 0 0 0 1]
    res = (sum(A==1,2)>1)
    This works row-wise for more than 1 rows