# How to find largest Peaks Values of signal and Save Corresponding X axis and Y Axis Values in MATLAB

2 visualizaciones (últimos 30 días)
Hammad Younas el 21 de Feb. de 2023
Comentada: Rik el 21 de Feb. de 2023
Hello, I have the following Dataset in which first column shows the X-axis and 2nd Column shows the Y-axis.
I want to find Peak Value as shown in the image below and
Save the X and Y axis Values Corresponding Peak. Y axis Values as Amplitude and X axis values as Time
After that I want to subtract 2nd peak from 1st peak, and 4th peak from 3rd Peak.
It should be general for example if i got 6 peaks then 2nd subtract from 1st then 4th from 3rd and 6th from 5th
How can i do that in MATLAB
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Rik el 21 de Feb. de 2023
Just in case you decide to edit this one away as well: I just made it pointless by attaching the original file to this comment.

Iniciar sesión para comentar.

### Respuestas (1)

Star Strider el 21 de Feb. de 2023
Editada: Star Strider el 21 de Feb. de 2023
Try this —
Dataset = LD.Dataset;
X = Dataset(:,1);
Y = Dataset(:,2);
[pks,locs] = findpeaks(Y, 'MinPeakProminence',0.01);
PeakData = table(X(locs),pks, [0;diff(X(locs))], [0; diff(pks)], 'VariableNames',{'Time','Peak Amplitudes','Peak Time Differences','Peak Amplitude Differences'})
PeakData = 4×4 table
Time Peak Amplitudes Peak Time Differences Peak Amplitude Differences __________ _______________ _____________________ __________________________ 6.3514e+05 0.026385 0 0 2.651e+06 0.026396 2.0159e+06 1.0358e-05 4.6668e+06 0.026394 2.0158e+06 -1.4018e-06 6.6827e+06 0.026396 2.0159e+06 1.6908e-06
figure
plot(X, Y)
hold on
plot(X(locs), pks, '+r')
hold off
grid
xlabel('Time')
ylabel('Amplitude')
EDIT — Corrected typographical errors.
.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Image Category Classification en Help Center y File Exchange.

R2022b

### Community Treasure Hunt

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

Start Hunting!

Translated by