Reputation: 335
The matrix <1x500> consists of different values, now I want to check if any of the values in the matrix occurs at least 3 times or more.
if (val occurs 3 times or more)
do
Help is very appreciated!
Upvotes: 0
Views: 49
Reputation: 35525
Another option from @KiW answer for when you need to know all the values that do appear at least 3 times is:
uniqA=unique(A);
counts=histcounts(A,[uniqA inf]);
vals_that_are_bigger=uniqA(counts>=3);
To check if any of them are bigger than 3, just
if any(counts>=3)
Upvotes: 6