Can I get he frequency of each value in a vector without a loop?

1 回表示 (過去 30 日間)
Carl
Carl 2015 年 6 月 12 日
回答済み: Azzi Abdelmalek 2015 年 6 月 12 日
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

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 6 月 12 日
out=hist(aa,UniqVal)

その他の回答 (1 件)

Ingrid
Ingrid 2015 年 6 月 12 日

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by