Find Average Peaks Function
8 次查看(过去 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!