MATLAB Matlab - count how many times a number occurs

  • Thread starter Thread starter jemma
  • Start date Start date
  • Tags Tags
    Count Matlab
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:
Physics news on Phys.org
Off the top of my head, you could try:

sum(x == 2)

To count the number of times 2 appears.
 

Similar threads

Back
Top