470 views (last 30 days)

Show older comments

Image Analyst
on 1 Nov 2015

The x values are the second return argument of findpeaks(). It's the index number. Your formula does not have an x by name so you have to go with the index number. If you have a second array for t, then to get the t values you'd do

[peakValues, indexes] = findpeaks(y);

tValues = t(indexes);

To get valleys, you invert the signal, so that now what used to be valleys are now peaks, and use findpeaks() again

invertedY = max(y) - y;

[peakValues, indexes] = findpeaks(invertedY);

tValues = t(indexes);

Markus Wahl
on 24 Nov 2018

Sergio Yanez-Pagans
on 28 Mar 2021

You can use my MATLAB file exchange function, it's really easy to implement and use:

Hope you find this useful!

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!