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

조회 수: 1 (최근 30일)
Tahariet Sharon
Tahariet Sharon 2021년 5월 18일
댓글: Tahariet Sharon 2021년 5월 21일
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?

답변 (1개)

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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by