Issue with finding the peaks of a graph.

2 次查看(过去 30 天)
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

采纳的回答

Star Strider
Star Strider 2018-1-7
I cannot figure out what you are doing, and specifically what ‘autom’ returns.
Try this instead:
plot(locs,pks,'k^','markerfacecolor',[1 0 0])
  6 个评论
Amy Wong
Amy Wong 2018-1-9
I understand. Thank you for your detailed explaination!
Do you know any other method to find the values and locations of the peaks instead of using the findpeaks function?
Star Strider
Star Strider 2018-1-9
As always, my pleasure.
There may be some peak-finding routines on the File Exchange. I have not used them, so have no experience with them.

请先登录,再进行评论。

更多回答(1 个)

Steven Lord
Steven Lord 2018-1-7
If the issue to which the title of your question refers is the X ticks of the last plot, that's because you called plot with one data input.
Calling plot(q) plots points (1, q(1)), (2, q(2)), (3, q(3)), ....
Calling plot(q, w) plots points (q(1), w(1)), (q(2), w(2)), (q(3), w(3)), ....
If that's not the issue about which you're asking with which you'd like us to help you, please state that issue clearly.
  1 个评论
Amy Wong
Amy Wong 2018-1-7
I have edited my question.
My issue is i do not understand why the peaks does not match my graph

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by