MATLAB: Issue with finding the peaks of a graph.

find peakshistogram

I would like to plot peaks on the autocorrelation graph. however, the findpeaks function does not give me the peaks of the autocorrelation graph. Is there something wrong with my code?
I have a histogram that looks like this:
I use this histogram to plot the autocorrelation:
and when I use the findpeaks function to find and plot the peaks, I get this:
my code is:
MINval = min(CODCT);
MAXval = max(CODCT);
width = 1;
h=hist(CODCT,floor(MINval):width:ceil(MAXval)); %histogram
x = h;
Rxx=autom(x); %autocorrelation
figure()
grid;
[pks,locs] = findpeaks(Rxx);
plot(Rxx);
hold on
plot(Rxx(locs),pks,'k^','markerfacecolor',[1 0 0]), hold off

Best Answer

I cannot figure out what you are doing, and specifically what ‘autom’ returns.
Try this instead:
plot(locs,pks,'k^','markerfacecolor',[1 0 0])