findpeaks ( 'WidthReference','halfheight' ) not finding width of peak
16 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
sarmad m
am 1 Apr. 2017
Kommentiert: Netanel shachak
am 5 Jun. 2023
Hi
I'm trying to find ( 'WidthReference','halfheight') something like this image
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/162504/image.png)
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/162505/image.jpeg)
0 Kommentare
Akzeptierte Antwort
Greg Dionne
am 4 Apr. 2017
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 Kommentare
Netanel shachak
am 5 Jun. 2023
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1403139/image.jpeg)
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;
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1403144/image.jpeg)
any suggust?
Weitere Antworten (2)
sarmad m
am 2 Apr. 2017
1 Kommentar
Amanda Figueroa
am 4 Jun. 2019
Bearbeitet: Amanda Figueroa
am 4 Jun. 2019
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):
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/223019/image.png)
Matlaber
am 14 Jan. 2019
Maybe you can paste your code here and have a look.
Are you able to find the peaks on your data?
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!