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
0 个评论
采纳的回答
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 个评论
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
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!