MATLAB Answers


How to find out distance among peaks from a plot?

Asked by Zara Khan on 5 Jul 2018
Latest activity Answered by Rahul punk on 15 Mar 2019
some binary intensity values have stored in a profile and has been plotted. And getting some peaks from it. Here plot function has been used. How to find out distance among the peaks?


doc findpeaks
if you have the Signal Processing toolbox
Yes. But distance I am not able to find

Sign in to comment.

2 Answers

Answer by 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


For different different graphs I am getting different different peaks. after counting no of peaks I want to find out distance between each of them means distance between first and second, between second and third and so on. How to do that ?
diff( locs )

Sign in to comment.

Answer by Rahul punk on 15 Mar 2019

%If y is your signal
% you have to specify what is the major peak
% Major peaks and indices
[major_peaks, index]=find(peaks>=min_peak)


Sign in to comment.