Am using matlab to detect peaks, how can I use it to find the area under the curve, average of data points between peak and valley, and slope?
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Is there a way to do this automatically all at once? I have some data, which I find the peaks of like so:
Peakdata=TaskData(:,k);
[Maxima,MaxIdx] = findpeaks(Peakdata,'MinPeakHeight',mean(Peakdata),'MinPeakDistance',10);
Troughdata=1.01*max(Peakdata)-Peakdata;
[Minima,MinIdx] = findpeaks(Troughdata,'MinPeakHeight',mean(Troughdata),'MinPeakDistance',10);
Minima = Peakdata(MinIdx);
I have several different data sets which I do this to and I get a list of all the peaks and troughs in the data (looks kinda like an imperfect sine wave) . I also want to number all peaks and then calculate the average of the data between each peak/trough. As well as the ascent/descent rates (slope) to get from each peak and trough. Then if possible calculate the area under the curve between each peak and trough. So not the hole area like a parabola but half the parabola.
0 Commenti
Risposte (2)
Image Analyst
il 5 Ago 2016
Modificato: Image Analyst
il 5 Ago 2016
Did you try mean() and sum()? Like
for k = 1 : length(MinIdx)-1
peakAverages(k) = mean(Peakdata(MinIdx(k):MinIdx(k+1)));
peakAreas(k) = sum(Peakdata(MinIdx(k):MinIdx(k+1)));
end
I'm assuming you have mins on each side of a max - i.e. like no peak on the edge not enclosed in between with trough mins.
3 Commenti
Clara Sánchez del Valle
il 11 Dic 2020
I did it this way and it worked for me.
[max, maxIdx] = findpeaks(Data);
DataInv = 1.01*max(Data) - Data;
[min, minIdx] = findpeaks(DataInv);
maxminIdx = [maxIdx minIdx];
maxminIdx = sort(maxminIdx);
maxmin = Data(maxminIdx);
0 Commenti
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!