Total number of zeros , ones , twos..etc in a matrix

조회 수: 6 (최근 30일)
Joydeb Saha
Joydeb Saha 2020년 12월 9일
댓글: Joydeb Saha 2020년 12월 9일
I have a matrix where in the fourth column there will be numbers of 0 to 23. I need a separate matrix where there will be the total numbers of 0s, 1s,2s ..23s etc. Say there will be 1000 0s, 3000 1s 24000 11s etc.
  댓글 수: 2
Elimelech Schreiber
Elimelech Schreiber 2020년 12월 9일
histcounts()
specifically for your problem:
histcounts(x(:,4), (-1:max(x(:,4)))+0.5)
Walter Roberson
Walter Roberson 2020년 12월 9일
편집: Walter Roberson 2020년 12월 9일
accumarray() together with findgroups(). Or use groupcounts()
I will not post code as I have a suspicion this is homework.

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

채택된 답변

KSSV
KSSV 2020년 12월 9일
Let a be your data array.
[count_unique, unique_a] = hist(a,unique(a)) ;

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by