Consider I have a m by n matrix with binary data
Is there a easy way to write a code that can identify the column with the least number of ones in them.
My current code identifies the column with zero 1s, which is not what I seek
H = [0 0 1 1 0 1 0 1 0 1 1 0; 0 0 0 1 0 1 1 0 1 0 1 0; 0 1 1 0 0 1 1 1 0 0 0 1; 0 1 1 0 1 0 1 0 1 0 0 0; 0 0 0 1 1 0 0 1 1 0 0 0; 0 1 0 0 1 0 0 0 0 0 1 1];%For ex, here the column with least number of ones is column 10.
%whereas column 1 has all zero elements which is not the result I want.
%This is my code which gives wrong results
a = sum(H);amax = max(a);amin = min(a);
Best Answer