Using unique-function - show amount of times unique value was found

조회 수: 1 (최근 30일)
Lukas Netzer
Lukas Netzer 2021년 5월 3일
댓글: Lukas Netzer 2021년 5월 3일
Hey,
I am using:
[C, ia, ic] = unique(Location);
Now I get a list of unique Locations in Location but am actually looking for the amount of times each location is in there. E.g.:
C Times
Location 1 5
Location 2 8
Location 3 2
etc..
Is there a way to do that?
thanks for your help!

채택된 답변

KSSV
KSSV 2021년 5월 3일
REad about hist.
xbins = unique(Location);
[counts,centres] = hist(Location,xbins);
R = [centres counts]

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by