Find Average Peaks Function
조회 수: 7 (최근 30일)
이전 댓글 표시
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
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
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'})
.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
