matlab - Compare 3 matrices and count the number of maximal number in each of them -


there 3 matrices same size a,b,c. want compare them entry entry , output 3 numbers number of maximal elements of each of 3 matrices (ignoring cases ties). how should efficiently in matlab?

example:

a = [1 2 1 2] b = [2 1 3 1] c = [3 1 2 3] 

the 1st entry c biggest, 2nd entry a biggest, 3rd b, 4th c, 3 numbers output are: 1, 1, 2, representing biggest entry in each of 3 matrices.

>> m = [a;b;c]; % concatenate single matrix >> [~,idx] = max(m); % index of maximum in each column >> vals = hist(idx, 1:size(m,1)) % make histogram of results  vals =       1     1     2 

Comments