How to get bin counts from max(histcount_plot)

3 Ansichten (letzte 30 Tage)
mohamed madani
mohamed madani am 5 Dez. 2016
Kommentiert: mohamed madani am 6 Dez. 2016
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.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 5 Dez. 2016
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 Kommentare
mohamed madani
mohamed madani am 6 Dez. 2016
How do you use the two-output version of max(). Is it something like 'max(Cnts,Bin)'?
mohamed madani
mohamed madani am 6 Dez. 2016
Nevermind, I figured it out. It works now. Thank you so much.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Jacob Ziesenis
Jacob Ziesenis am 5 Dez. 2016
I would try:
find(N==max(N))
  1 Kommentar
Walter Roberson
Walter Roberson am 5 Dez. 2016
Note: this can give you multiple outputs, if the maximum happens to be duplicated.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by