# How to find the locations or indices of lower and upper ends of FWHM of a peak

2 Ansichten (letzte 30 Tage)
Vinay Killamsetty am 14 Jul. 2021
Kommentiert: Simon Chan am 14 Jul. 2021
How to find the locations and Index of lower and upper limit of FWHM of the largest peak shown in the pic below
Whn I use findpeaks function I am able to get the FWHM but I find it hard to get the location/index of the upper and lower limits of the FWHM
since there exists another peak in the range having a peak value above the half maximum of the main peak.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Simon Chan am 14 Jul. 2021
Bearbeitet: Simon Chan am 14 Jul. 2021
Suppose y is the data, try this:
You may change the interpolation method, mine is only an example.
The location of the limits on the left side is between idx1 & idx1+1,
while on the right side, it is between idx2-1 & idx2.
[~,location] = max(y);
yn = y/max(y); % Normalized data
idx1 = location - find(diff(yn(location:-1:1)>0.5)~=0,1,'first');
idx2 = location + find(diff(yn(location:1:end)>0.5)~=0,1,'first');
xaxis_left = interp1([yn(idx1), yn(idx1+1)], [x(idx1), x(idx1+1)], [yn(idx1), 0.5, yn(idx1+1)], 'linear');
xaxis_right = interp1([yn(idx2-1), yn(idx2)], [x(idx2-1), x(idx2)], [yn(idx2-1), 0.5, yn(idx2)], 'linear');
FWHM = xaxis_right(2) - xaxis_left(2)
##### 2 KommentareKeine anzeigenKeine ausblenden
Vinay Killamsetty am 14 Jul. 2021
Dear , Simon Chan
Thank you very much for your answer. Infact it helped me in solving the problem.
Do you have any suggestion for finding the location of the first minimum on both sides of the main peak
Simon Chan am 14 Jul. 2021
Try this:
idx3 and idx4 are the minimum points on the left and right side respectively.
Hope it helps
idx3 = location - find(diff(yn(location:-1:1))>0,1,'first') + 1;
idx4 = location + find(diff(yn(location:1:end))>0,1,'first') - 1;

Melden Sie sich an, um zu kommentieren.

### Weitere Antworten (1)

KSSV am 14 Jul. 2021
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Vinay Killamsetty am 14 Jul. 2021
Bearbeitet: Vinay Killamsetty am 14 Jul. 2021
Deat KSSV,
Thank you very much for your suggestion.
I have used the below command as you have suggested
knnsearch(x,y,'k',2)
But this function has helped me in finding the location of higher end of the FWHM but it is giving an inappropriate value for the location oflower end FWHM.
Instead of loacting the lower end of FWHM it is giving me some location from 1st peak

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Descriptive Statistics finden Sie in Help Center und File Exchange

R2020b

### Community Treasure Hunt

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

Start Hunting!

Translated by