Matlab code to find the most repeatedly occuring highest value in the array.
3 views (last 30 days)
Show older comments
Hi everybody I have the following list of numbers and I want to find the most repeatedly occuring highest value. I tried using mode but it gives ne the most repeatedly occuring lowest value. How can I get the most repeated highest value?
Also if my number is the format 4.566754E-11 or 3.9972378E-10 is there anyway I can make matlab ignore the E-11 oe E-10 tempüorarily and just round the value to one numver after decimal point?
eg: 4.566754E-11 --> 4.6E-11
I have attached in an excel sheet some values which I have in my matlan array for your reference.
Looking forward to your help.
1 Comment
Jan
on 17 May 2015
If I understand correctly: You are looking for the most frequent value in an array, and if there are several values appearing with the same frequency the highest value is wanted. Correct?
Answers (2)
Image Analyst
on 14 May 2015
You could try this:
a = [7 8 6 6 8 8 9 10 8 6 8 8 6 6 6]
[counts, edges] = histcounts(a)
modeIndexes = find(counts == max(counts))
greatestMode = ceil(edges(modeIndexes(end)))
0 Comments
Jan
on 13 May 2015
Edited: Jan
on 13 May 2015
You are looking for two different criteria: Most frequent and highest. This is simply impossible. You can find either the most frequent value, or the highest. Please give us a meaningful definition with a small example of what you want to achieve.
There are a lot of rounding function, simply search for "Matlab round significant digits". Should be digits be ignored for the calculations or for the display only?
4 Comments
Jan
on 17 May 2015
mode() replies the most frequent value, so the multiplication by -1 is not a reliable method to prefer the higher values.
You have written: "I tried rounding but that just rounds my number to zero since the values I have are very small." Please post how you tried to round. Then we can suggest an improvement.
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!