Here is my signal where i need to number the peaks and troughs in numbers as 1,2,3,4...
Neeta Dsouza answered .
2025-11-20
numPoints = 50; x = sort(rand(1, numPoints)); y = rand(1, numPoints); plot(x, y, 'k-', 'LineWidth', 2); grid on; [peakValues, indexesOfPeaks] = findpeaks(y); hold on; peakx = x(indexesOfPeaks); peaky = y(indexesOfPeaks); plot(peakx, peaky, 'r*', 'LineWidth', 2, 'MarkerSize', 10); % Find valleys on inverted signal [valleyValues, indexesOfValleys] = findpeaks(-y); valleyx = x(indexesOfValleys); valleyy = y(indexesOfValleys); hold on; plot(valleyx, valleyy, 'b*', 'LineWidth', 2, 'MarkerSize', 10);
