Suppose I have the F matrix like this:
F =
0, 0, 106, 10, 14, 20, 20, 23, 27, 26, 28, 28, 28, 23
| | |
peak peak peak
I'm using the command plot(F). I want to get the indexes of the peaks in the data.
This is the code I have so far, it does not work:
[max_x,index_x]=max(x);
e=index_x;
for i=1:11
index_x(i)=e;
e=e+16;
end
Is there a builtin function in matlab that will do this for me?
klurie
Use the findpeaks function (Signal Processing Toolbox).
[peakVal,peakLoc]= findpeaks(x);
anirudh
Well here is what I prefer:
[maxval maxloc] = max(A(:));
来源:https://stackoverflow.com/questions/15583989/finding-the-location-of-maximum-peaks-in-a-plot-with-matlab