Cody

Problem 36. Find relatively common elements in matrix rows

Created by Cody Team in Community

You want to find all elements that exist in greater than 50% of the rows in the matrix.

For example, given

 A =
     1 2 3 5
     9 2 5 9
     3 2 5 8
     1 2 1 5
     5 1 3 2

the answer would be the row vector

 [1  2  3  5]

since each of these appears three or more times in the rows of matrix A. Elements should be returned sorted ascending.

Note there is no guarantee that there are any such elements; if there are none, the routine should return the empty set. Also, the matrix might contain repeats, very large or very small numbers, or NaNs (though NaN should not be treated as a number to be returned in the output).

Solution Stats

37.98% Correct | 62.02% Incorrect
Last solution submitted on Feb 16, 2019

Problem Comments

Solution Comments

Recent Solvers559

Suggested Problems

More from this Author95

Tags

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!