MATLAB: How to find x range value and calculate average of corresponding peaks in a graph signal

averagepeaks

Hi everybody,
I need help for this task: I have a graphs with irregular peaks derived from matrices data and I would like to automatically calculate for each set of data the x range where peaks occur and the mean value of each peak.
I hope I will be more clear showing an example. Every peak in the bigger graph corresponds to a series of irregular peaks (an example is shown in the little graph, which represents the first peak).
Thanks for attention!

Best Answer

Try this;
index = find(y>100); % find peaks
ind = find( diff(x(index)) > 0.01 ); % find start and end of peak searies
index = [index(1) index(ind+1); % first row - start of series
index(ind) index(end)]; % second row - end series