MATLAB: How to plot a best-fit curve over local maxima

best-fit curvecoordinatesextremafindpeaksmaxima

Hello – Is there a way to identify the local maxima coordinates that are found using the "findpeaks" function?
For data with multiple peaks, I am interested in calculating an array of points for plotting a best-fit curve over the local maxima.
Thank you!
Mark

Best Answer

The findpeaks function can give two outputs if you ask for them, the amplitudes of the peaks and their locations. With respect to the fitting function, it depends what you want. Use the polyfit and polyval functions if you want parameters on the fit (a polynomial order greater than 7 is not likely to yield better results, and it is best to use the lowest order that will reasonably fit). Another option is spline if you are not interested in the parameters.