I have found a way to do this. It might not be the most efficient way, but it works for what I want. Basically, the histogram function creates a class with a bunch of components like an array that lists the boundaries of each bin (h.BinEdges), and an array (h.Values) that lists the values for each bin (how many components of the raw data fits inside that bin). The histogram itself is basically a bar graph of h.BinEdges vs. h.Values.
So I'm finding all of the local maxima within the Values and then matching up the index to find the BinEdges of the maxima. And then I'm replacing that max with 0 so that the next iteration of that procedure will now find the second highest local maxima. The end result is that durationmax1, durationmax2, and durationmax3 will show the three most prevalent values of duration.
r = round(range(duration));
h = histogram(duration,round(r/4));
[pks,locs,w,p] = findpeaks(h.Values);
count = 0;
for i = 1:length(pks)
if(pks(i) == max(pks))
count = i;
pks(i) = 0;
break
end
end
durationmax1 = (h.BinEdges(locs(count)) + (h.BinEdges(locs(count) + 1)))/2;
for i = 1:length(pks)
if(pks(i) == max(pks))
count = i;
pks(i) = 0;
break
end
end
durationmax2 = (h.BinEdges(locs(count)) + (h.BinEdges(locs(count) + 1)))/2;
for i = 1:length(pks)
if(pks(i) == max(pks))
count = i;
pks(i55) = 0;
break
end
end
durationmax3 = (h.BinEdges(locs(count)) + (h5.BinEdges(locs(count) + 1)))/2;
end