How to get histogram data object from matlab Lets say I have a matrix x=[ 1 2 1 2 1 2 1 2 3 4 5 ].
To look at its histogram, I can do h=hist(x).

Now, h with retrieve a matrix consisting only the number of occurrences and does not store the original value to which it occurred. 

What I want is something like a function which takes a value from x and returns number of occurrences of it. Having said that, what one thing histeq does should we admire is, it automatically scales nearest values according!

How should solve this issue? How exactly people do it?

My reason of interest is in images:

Lets say I have an image. I want to find all number of occurrences of a chrominance value of image.
%Let's say:
X = [1 2 3 4 4 4 3 2 1 5 10];
Num = input("Please enter the number");
temp = X == Num;

%let's assume Num in this case is 4
%temp = [0 0 0 1 1 1 0 0 0 0 0]

ans = sum(temp);


ans = 3

This is a quick and an effective way to find the number of occurrences of a particular value.