If we have a discrete random variable x and the data pertaining to it in X(n), how in matlab can we determine the probability mass function pmf(X)?
If I understood correctly what you need to do is to estimate the pdf, except it is not continuous but discrete values.
Calculate the occurrences of different values in X(n) and divide by n. To illustrate what I am saying, please allow me to give an example. Assume that you have 10 observations:
X = [1 1 2 3 1 9 12 3 1 2]
then your pmf would look like this:
pmf(X) = [0.4 0.2 0.2 0 0 0 0 0 0.1 0 0 0.1]
edit: this is in principle a frequency histogram, as @zellus has also pointed out