MATLAB: Finding the Frequency of Unique Values frequency of unique values How to return the frequency of each value in array A? (So, B views there are 3, 1, 4, and 2 of 1, 2, 3, and 4, respectively) A = [ 1 1 4 3 3 3 3 2 4 1 ] B = [ 3 1 4 2] Best Answer A = [ 1 1 4 3 3 3 3 2 4 1 ][ii,jj,kk]=unique(A)freq=accumarray(kk,1)out=[ii' freq]%orfreq=hist(A,1:4) Related SolutionsMATLAB: How can i find an eleiment which comes only one in a matrix ???? A=[1 2;1 3;1 4;1 5;2 4][ii,jj,kk]=unique(A)b=accumarray(kk,(1:numel(kk))',[],@numel)out=ii(b==1) MATLAB: How to count number of words in a text file A={'HJK.BT' 'KLP.OK' 'HJK.BT' 'POL.ST' 'HJK.BT' 'POL.ST'}[ii,jj,kk]=unique(A)freq=accumarray(kk,1)out=[ii num2cell(freq)] Related QuestionFrom a=[1 2 3 4] to b=[1 1 2 2 3 3 4 4]Retrieving minimum values for parts of a matrixHow to create the array [1, 2,2 ,3, 3, 3, 4,4 4, 4]Quick method to find duplicates in a matrixRemove array values with multiple occurances from “parent” array
Best Answer