Find Average Peaks Function

7 Ansichten (letzte 30 Tage)
Nathan Johnson
Nathan Johnson am 22 Sep. 2023
Beantwortet: Star Strider am 22 Sep. 2023
I'm trying to find the average peaks from a code script I made. I currently am using the "findpeaks" function with a minimum y-axis value necessary. Example is
[pksR1,LcsR1]=findpeaks(filt_RLE,"MinPeakHeight",55);
What function can I call to get the mean bewteen the peaks within the code.
  1 Kommentar
Dyuman Joshi
Dyuman Joshi am 22 Sep. 2023
"What function can I call to get the mean bewteen the peaks within the code."
You want to find the mean of all the peaks you obtained?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Star Strider
Star Strider am 22 Sep. 2023
The mean value of the function between any two peaks would be —
x = linspace(0, 10, 250).';
filt_RLE = 50 * sin(2*pi*x*1.5) .* cos(2*pi*x/10) + 30;
[pksR1,LcsR1]=findpeaks(filt_RLE,"MinPeakHeight",55);
LcsR1 = LcsR1.';
for k = 1:numel(LcsR1)-1
meanv(k,:) = mean(filt_RLE(LcsR1(k) : LcsR1(k+1)));
end
figure
plot(x, filt_RLE)
hold on
plot(x(LcsR1), filt_RLE(LcsR1), 'r^')
hold off
yline(55, '--k')
Results = table(x(LcsR1(1:end-1)), x(LcsR1(2:end)),meanv, 'VariableNames',{'Peak Start','PeakEnd','Mean'})
Results = 9×3 table
Peak Start PeakEnd Mean __________ _______ ______ 0.16064 0.84337 33.377 0.84337 1.4859 30.741 1.4859 3.8554 31.279 3.8554 4.498 30.966 4.498 5.1807 33.565 5.1807 5.8233 30.875 5.8233 6.506 32.694 6.506 8.8353 30.744 8.8353 9.5181 33.229
.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by