I was trying to understand on how to detect the two peaks from the histogram. There can be multiple but I need to pick the two highest. Basically what I need to to is that although I will have these peaks shifted left or right, I need to get hold of them. Their spread can vary and their PEAK values might change so I have to find a way to get hold of these two peaks in Matlab.
What I have done so far is to create a 5 value window. This window is populated with values from the histogram and a scan is performed. Each time I move 5-steps ahead to the next value and compare the previous window value with current. Which ever is greater is kept.
Is there a better way of doing this?

Return data from hist (or histc) function to a variable (
y = hist(x,bin);) and use PEAKFINDER FileExchange submission to find local maximums.I have also used PEAKDET function from Eli Billauer. Works great. You can check my answer here with code example.