Have a look at Determine and count unique values of an array.
Or, to count the number of occurrences of 5, simply do
sum(your_matrix == 5)
Have a look at Determine and count unique values of an array.
Or, to count the number of occurrences of 5, simply do
sum(your_matrix == 5)