Can I get he frequency of each value in a vector without a loop?
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a vector which contains discrete values and I want to know hte frequency of each value. I have managed to get the result using a loop but I was wondering if it is possible to speed to process up.
aa=floor((10*rand(10,1)))*10 UniqVal=0:10:100; cat = length(UniqVal); bb=zeros(1,cat); for k=1:cat bb(k)=sum(aa==UniqVal(k)); end
댓글 수: 0
채택된 답변
추가 답변 (1개)
Ingrid
2015년 6월 12일
here you can find many useful tips: http://www.mathworks.com/matlabcentral/answers/96504-how-can-i-count-the-occurrences-of-each-element-in-a-vector-in-matlab
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!