finding the start and end points of a unimodal peak
15 views (last 30 days)
Show older comments
Teshan Rezel
on 31 Jan 2022
Answered: Star Strider
on 31 Jan 2022
Hi folks,
I am trying to automate the finding of the start and end of a peak. Many of the peaks I am looking at are gaussian. However, some of them are not.
Below are some of the results of using the findpeaks() function, using the width of the peak to deduce the start and end positions. As you can see, the results are not very promising!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/880005/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/880010/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/880015/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/880020/image.png)
3 Comments
Turlough Hughes
on 31 Jan 2022
Ah ok, so it's just one curve per experiment then, that's good to know. Could you attach the data (or something representative) as a .mat file and inidicate the ideal start and end positions?
Accepted Answer
Star Strider
on 31 Jan 2022
The findpeaks function might not be the best option here.
Experiment with ischange and findchangepts (Signal Processing Toolbox) to see if they will give the desired result.
0 Comments
More Answers (1)
John D'Errico
on 31 Jan 2022
Edited: John D'Errico
on 31 Jan 2022
Wait a second! You are using findpeaks. It returns as one argument the peaks it finds, as well as the associated width. But you are using it on asymmetric peaks. Simply assuming that taking the peak, plus or minus half the width is silly if that peak is not a nice, symmetric curve.
For example,
x = linspace(0,1.25,1000);
y = sin(x.^10).^2;
plot(x,y)
hold on
[peaks,locs,w] = findpeaks(y,x)
So it found a peaks at x= 1.1717, with a width of 0.4073.
Now are you seriously going to claim it is a good idea to use that width, as if the peak was symmetric?
xline(locs(1),'r')
xline(locs(1) + w(1)/2*[-1,1],'g')
The peaks you show are strongly asymmetric. They do not look even remotely look like a gaussian. I would expect something silly to happen if you arbitraily treat the peak as symmetric when you use the width returned.
Far more logical might be, since these seem to be unimodal curves, is to use findpeaks only to locate the peak location itself.
Now, since you know the baseline. Find the point where an interpolated approximation of that curve crosses the 10% point, thus a level at 10% of the difference from the baseline to the peak. There should be two such locations. I chose the 10% point arbitrarily, so it will be sufficiently above any baseline junk, yet reasnably close to the baseline.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!