I am new to Matlab and I am not sure how to find the coordinates of the peaks or valleys of my graph. After looking online, I tried using findpeaks() which did give me the y-values of the local maxima of my function ((e^(−at))*cos(2πft), where t is time and a and f are constants). However, I have not been able to find the corresponding x-values (and findpeaks() omits a local max at the y-intercept). I am also not at all sure how to find the coordinates for the valleys (minima or "troughs").
John Michell answered .
2025-11-20
[peakValues, indexes] = findpeaks(y); tValues = t(indexes);
invertedY = max(y) - y; [peakValues, indexes] = findpeaks(invertedY); tValues = t(indexes);