Matlab - count how many times a number occurs

  • Topic: MATLAB 
  • Thread starter jemma
  • Start date
  • Tags Tags
    Count Matlab
1 reply · 10K views · last reply
jemma
Messages
35
Reaction score
0
Suppose

x =

1 2 3 4
1 2 3 4
5 6 7 8
1 2 3 4
5 6 7 8

I need a function to count how many times each set of number occurs
eg.
1 2 3 4 occurs 3 times
5 6 7 8 occurs 2 times

Thanks!
 
Last edited:
Off the top of my head, you could try:

sum(x == 2)

To count the number of times 2 appears.