MATLAB: Count value in an array

digital image processing

i have an array about 252 x 252 cells from the excel file, it have many values from 1 to 256, so i want to count how many times each of value appear in this array like frequency and cummulative? example ( just a small array):
and the result like as :
i did it in excel but i don't know how to do it in Matlab.
Thank you so much with any help!!

Best Answer

It is impossible to get the data out of your figure file, but I downloaded the subset of data you posted earlier. I’m including it here for others to work with.
To get counts of the various values, use histc, and to plot them, use bar:
A = [52 53 51 52 55 59 61 61 61 59 56 51 54 52 49 49 55 61 67 68 69 67 63 56 49 46 44 48 58 66 77 74 71 70 67 61 45 44 45 52 63 72 78 74 69 65 62 57 45 46 48 55 65 73 76 72 65 59 55 51 50 51 52 54 59 63 66 63 59 54 50 47 49 51 50 49 48 48 51 51 50 49 47 44 41 42 42 41 40 39 39 41 43 43 40 38 35 33 33 35 37 37 35 37 37 35 32 30 35 30 29 32 36 38 36 36 34 29 26 26 41 37 31 27 30 36 36 36 34 29 23 23 39 35 30 25 27 32 35 35 34 29 24 24 32 30 26 22 22 26 34 35 34 30 26 25 24 25 25 22 22 23 35 36 35 32 29 28 22 26 31 31 30 30 38 38 36 33 31 31 26 34 43 45 42 40 40 38 35 32 31 31 30 40 51 53 49 45 40 37 32 29 28 30 31 41 53 55 49 45 40 35 30 26 26 28 37 44 49 48 44 42 36 37 32 25 21 25 41 47 50 45 39 36 41 42 37 29 25 29 47 53 54 47 39 36 47 47 43 35 31 34 51 59 59 51 44 43 48 49 45 38 35 39 54 61 59 50 44 44 46 48 45 38 37 42 58 61 54 42 38 40 45 47 44 38 37 42 64 63 51 38 36 40 48 49 46 38 36 40 69 66 53 40 39 45 51 52 48 39 36 39 70 63 51 43 44 49 54 48 41 38 39 43 67 61 52 45 44 46 50 47 43 43 48 53];
Amm = [min(A) max(A)]; % Find range of data
bins = Amm(1):Amm(2); % Create bin locatins
c = histc(A, bins); % Generate histogram (frequency) counts
cc = cumsum(c); % Cumulative counts in bin order
figure(1) % Plot histogram
bar(bins, c)