필터 지우기
필터 지우기

How to get bin counts from max(histcount_plot)

조회 수: 4 (최근 30일)
mohamed madani
mohamed madani 2016년 12월 5일
댓글: mohamed madani 2016년 12월 6일
I have a histcount plot which uses two different vectors. I called them 'Peak' and 'Bin'. The 'Bin' is obviously bins and 'Peak' is the data that goes in each bin. So then I made a histcount; Cnts=histcounts(Peak,Bin). Now I need a way to find the peak that this histcount will give. By peak, I mean finding the highest count and then find the corresponding bin number. I then need to plot those along with the histcount which I can do using the 'hold' command. I'm just having a problem with finding the Bin number that has the highest counts.

채택된 답변

Walter Roberson
Walter Roberson 2016년 12월 5일
Use the two-output version of max() applied to Cnts. The second output gives you bin number and you can use it to index bins to get the location
  댓글 수: 2
mohamed madani
mohamed madani 2016년 12월 6일
How do you use the two-output version of max(). Is it something like 'max(Cnts,Bin)'?
mohamed madani
mohamed madani 2016년 12월 6일
Nevermind, I figured it out. It works now. Thank you so much.

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

추가 답변 (1개)

Jacob Ziesenis
Jacob Ziesenis 2016년 12월 5일
I would try:
find(N==max(N))
  댓글 수: 1
Walter Roberson
Walter Roberson 2016년 12월 5일
Note: this can give you multiple outputs, if the maximum happens to be duplicated.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by