Find Average Peaks Function

조회 수: 7 (최근 30일)
Nathan Johnson
Nathan Johnson 2023년 9월 22일
답변: Star Strider 2023년 9월 22일
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
Dyuman Joshi
Dyuman Joshi 2023년 9월 22일
"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?

댓글을 달려면 로그인하십시오.

답변 (1개)

Star Strider
Star Strider 2023년 9월 22일
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
.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by