Get frequency table (sorted alphabetically)

s = {'A','E','C','B','E','B','E','A'}

tabulate(sort(s))

    Value    Count   Percent

      A        2     25.00%

      B        2     25.00%

      C        1     12.50%

      E        3     37.50%


Get frequency table (sorted in descending order of percentages)

s  = {'A','E','C','B','E','B','E','A'}

t  = tabulate(s)

ts = sortrows(t,3,'descend')

    {'E'}    {[3]}    {[37.5000]}

    {'A'}    {[2]}    {[     25]}

    {'B'}    {[2]}    {[     25]}

    {'C'}    {[1]}    {[12.5000]}

for i=1:size(ts,1)

  fprintf(1, ' %s\t%d\t%.2f%%\n', ts{i,:})

end

  E 3 37.50%

  A 2 25.00%

  B 2 25.00%

  C 1 12.50%


https://mathworks.com/help/stats/tabulate.html