MATLAB: How to plot a histogram of repeated values in a matrix

histogramMATLAB

I have a matrix like below.
X = [120 2 3 250 60; 4 5 6 120 250; 7 8 3 250 10]
I want to plot a histogram shows the number of times a value is repated in each columns for example in first 120 in repeated 2 times in this matrix 250 is repeated 3 times in this matrix. any solution ?

Best Answer

This computes how often each value occurs
[a b c] = unique(X);
[X(b) histc(c, 1:max(c))]