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

3 vues (au cours des 30 derniers jours)
Tahariet Sharon
Tahariet Sharon le 18 Mai 2021
Commenté : Tahariet Sharon le 21 Mai 2021
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?

Réponses (1)

KSSV
KSSV le 18 Mai 2021
Let a be column.
xbins = unique(a);
[counts,centres] = hist(a,xbins);
R = [centres counts']
  1 commentaire
Tahariet Sharon
Tahariet Sharon le 21 Mai 2021
Thanks. However, my variable a is a list of names of countries
{'US'}
{'China'}
etc.
This code seems to work with nummerical data.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by