counting total no of particles in a bin in histogram

조회 수: 2 (최근 30일)
Sumera Yamin
Sumera Yamin 2019년 8월 23일
댓글: dpb 2019년 8월 23일
Hi, i have a basic problem. I had made a histogram with nbins = 100.
I want to count the number of particles of that which is maximum number of particles and display it.
what should be the best way to do it.
Thank you very much. Any help is highly appreciated.
  댓글 수: 3
Ted Shultz
Ted Shultz 2019년 8월 23일
Did you try looking at the counts property of the histogram object?
Sumera Yamin
Sumera Yamin 2019년 8월 23일
편집: Sumera Yamin 2019년 8월 23일
x = randn (100,1);
n = 100;
hist (x, n);
minz = min (x);
maxz = max (x);
n_bin = (maxz-minz) / n;
% i want to locate the bin with highest number of counts and then divide total sum of that bin with n_bin.

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

채택된 답변

Saurabh Kelkar
Saurabh Kelkar 2019년 8월 23일
k = hist(x,n);
gives the counts in each of the bins.
modalBin = find(k==max(k) % Gets the bin number of highest bin. Will return two bins if clashes
Alternatively i would recommend using ecdf funtion for doing this.
  댓글 수: 5
Ted Shultz
Ted Shultz 2019년 8월 23일
It looks like hist is discouraged by mathworks...
dpb
dpb 2019년 8월 23일
Indeed, but there are some real advantages with them with respect to the new versions...the binning difference above being one and the ease in setting bins for certain specific uses. "Not everything new is necessarily improved."

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by