findpeaks ( 'WidthRefe​rence','ha​lfheight' ) not finding width of peak

Hi
I'm trying to find ( 'WidthReference','halfheight') something like this image
but it is not showing using this code , could you please show
me where is my error .
order =3 ;
framelen =13;
Averages=[R,L]';
Averages=mean(Averages)';
AV=smooth(Averages,6);
x=AV;
lx = 20;
sgf = sgolayfilt(x,order,framelen);
plot(sgf);
hold on;
findpeaks(sgf,'MinPeakProminence',0.003);
[pks,locs,widths,proms]=findpeaks(sgf,'Annotate','extents','WidthReference','halfheight');
pks= -pks;
plot(locs,pks,'g*');
text(locs+.02,pks,num2str((1:numel(pks))'));
this the output I get

 채택된 답변

Greg Dionne
Greg Dionne 2017년 4월 4일
I think you wanted this instead:
findpeaks(sgf,'MinPeakProminence',0.003,'WidthReference','halfheight','Annotate','extents');
[pks,locs,widths,proms]=findpeaks(sgf,'MinPeakProminence',0.003,'WidthReference','halfheight');
(use the same settings for when you plot without output arguments vs. when you do your assignment).

댓글 수: 4

I did what you suggested to me like this : but again not showing the halfheight or peaks , what is wrong ?
order =9 ;
framelen =13;
x=-AV;
lx = 20;
sgf = sgolayfilt(x,order,framelen);
plot(sgf);
hold on;
sgf=-sgf;
findpeaks(sgf,'MinPeakProminence',0.006,'WidthReference','halfheight','Annotate','extents');
[pks,locs,widths,proms]=findpeaks(sgf,'MinPeakProminence',0.006,'WidthReference','halfheight');
pks = -pks;
plot(locs,pks,'g*');
text(locs+.02,pks,num2str((1:numel(pks))'));
It's probably not liking the fact that you're using the 'halfheight' flag with a negative baseline. Since your peak values are negative, your reference level needs to be brought up. My guess is you want to add +0.02 to sgf to bring up the baseline. (say "sgf = 0.02-sgf" instead of "sgf = -sgf".
thanks it works now
Hi,
Is there any way to determined spacific width indipendent the peak height?
i have a signal of pump (RPM) - i'm looking for time interval that the the RPM was above a spacific value with a width grater than a spacific value. for example:
i tried using findpeaks:
m=10;
pks=110;
findpeaks(Y,t,'Annotate','extents','MinPeakWidth',minutes(m),'MinPeakHeight',pks);
but in that case it find point with:
pks>110 & width=pks/2;
any suggust?

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

추가 답변 (2개)

sarmad m
sarmad m 2017년 4월 2일

0 개 추천

I'm using R2017a version .I tried the example that in the documentation and it shows the halfheight correctly . but when I try it on my data it not showing them

댓글 수: 1

I had the same issue until I removed the outputs (pks, locs, widths,proms)
[pks,locs,widths,proms] = findpeaks(Peaks(:,2),Peaks(:,1),...
'MinPeakHeight',4e7,'MinPeakProminence',4e6,'Annotate','Extents'...
);
The plot should show up if you remove them as shown below:
findpeaks(Peaks(:,2),Peaks(:,1),...
'MinPeakHeight',4e7,'MinPeakProminence',4e6,'Annotate','Extents'...
);
And this is my plot (zoomed in):

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

Matlaber
Matlaber 2019년 1월 14일

0 개 추천

Maybe you can paste your code here and have a look.
Are you able to find the peaks on your data?

카테고리

질문:

2017년 4월 1일

댓글:

2023년 6월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by