Matlab code to find the most repeatedly occuring highest value in the array.

4 Ansichten (letzte 30 Tage)
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 Kommentar
Jan
Jan am 17 Mai 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?

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Image Analyst
Image Analyst am 14 Mai 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)))

Jan
Jan am 13 Mai 2015
Bearbeitet: Jan am 13 Mai 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 Kommentare
Snehalatha
Snehalatha am 17 Mai 2015
Bearbeitet: Jan am 17 Mai 2015
I didn't do any rounding as round() function rounded all my digits to zero. So I just used the following program without rounding
function[maxPDCharge,freqMaxPD]=getmaxcharge(chargeValues)
%to make the max value the minimum multiply by -1
chargeValues= (-1*chargeValues);
% use mode function to find the minimum value of array which is
% actually our maximum
[maxPDCharge,freqMaxPD]=mode(chargeValues);
%disp the actual PD value using absolute function
maxPDCharge = abs(maxPDCharge);
end
mode() selects the minimum value. so I multiplied my array with -1 and used mode thereby selecting the maximum value
[EDITED, Jan, Code formatted]
Jan
Jan am 17 Mai 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.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by