How to find out distance among peaks from a plot?
Show older comments
Answers (2)
Wooshik Kim
on 5 Jul 2018
findpeaks gives you location of the peak as well
[pks,locs] = findpeaks(PeakSig,x);
dist = locs(2) - locs(1); %or whichever two peaks you want to know about
2 Comments
Adam
on 6 Jul 2018
diff( locs )
Rahul punk
on 15 Mar 2019
0 votes
%If y is your signal
x=10:0.1:100;
y=100*cos(x)./x;
plot(x,y)
% you have to specify what is the major peak
min_peak=2
[peaks,idx1]=findpeaks(y)
% Major peaks and indices
[major_peaks, index]=find(peaks>=min_peak)
indices=idx1(index)
%distances
distances=mean(diff(indices))
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!