Findind repeated elements in a cell of a Table and report number of cases

I have a table for which I would like to find how many times a certain item is repeated (for one column [variable] only at a time), and have the number of times it happens (sorted optimally). What is the way around this?

Answers (1)

Let a be column.
xbins = unique(a);
[counts,centres] = hist(a,xbins);
R = [centres counts']

1 Comment

Thanks. However, my variable a is a list of names of countries
{'US'}
{'China'}
etc.
This code seems to work with nummerical data.

Sign in to comment.

Categories

Tags

Asked:

on 18 May 2021

Commented:

on 21 May 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!