MATLAB: How to find the mean peaks in positive axis

findpeaks decode signal peaks mean amplitude

I wish to find the mean of all peaks from the positive axis in Figure 1.
I tried
pks = findpeaks(y);
but it includes some negatif value.
How to filter out the nagative peaks and remain the positive peaks?

Best Answer

thresh=0; % or whatever level you wish
pks = findpeaks(y,'MinPeakHeight',thresh);
Read the doc carefully; findpeaks has all kinds of options you'll probably find useful.