필터 지우기
필터 지우기

Finding the Frequency of Unique Values

조회 수: 19 (최근 30일)
Rightia Rollmann
Rightia Rollmann 2016년 8월 13일
편집: Azzi Abdelmalek 2016년 8월 13일
How to return the frequency of each value in array A? (So, B views there are 3, 1, 4, and 2 of 1, 2, 3, and 4, respectively)
A = [ 1 1 4 3 3 3 3 2 4 1 ]
B = [ 3 1 4 2]

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 8월 13일
편집: Azzi Abdelmalek 2016년 8월 13일
A = [ 1 1 4 3 3 3 3 2 4 1 ]
[ii,jj,kk]=unique(A)
freq=accumarray(kk,1)
out=[ii' freq]
%or
freq=hist(A,1:4)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by