Find Average Peaks Function
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Dyuman Joshi
le 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?
Réponses (1)
Star Strider
le 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'})
.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!