MATLAB Answers

how to find out full width at half maximum from this graph

529 views (last 30 days)
  3 Comments
Image Analyst
Image Analyst on 1 Nov 2016
OK, I've modified my answer below to take into account that your FWHM value is not based on the max but based on being between the min and the max.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 1 Nov 2016
Edited: Image Analyst on 24 Aug 2018
Use max():
% Find the half max value.
halfMax = (min(data) + max(data)) / 2;
% Find where the data first drops below half the max.
index1 = find(data >= halfMax, 1, 'first');
% Find where the data last rises above half the max.
index2 = find(data >= halfMax, 1, 'last');
fwhm = index2-index1 + 1; % FWHM in indexes.
% OR, if you have an x vector
fwhmx = x(index2) - x(index1);
  22 Comments
Image Analyst
Image Analyst on 31 Jul 2021
You either need to just add in the offset you searched from, like 20,000 to the index,
index1 = find(vq1(kkkkkk,20000:35000) >= halfMax, 1, 'first');
index1 = index1 + 19999; % Get index relative to the original length of the vector, not the cropped length.
or just mask out the stuff you don't want so it's not found
vq1(kkkkkk, 1:19999) = -inf;
vq1(kkkkkk, 35001:end) = -inf;
index1 = find(vq1(kkkkkk,20000:35000) >= halfMax, 1, 'first');

Sign in to comment.

More Answers (1)

Maks
Maks on 24 Aug 2018
Edited: Maks on 24 Aug 2018
It should be "more or equal" for the first index: index1 = find(data >= halfMax, 1, 'first');
  3 Comments
Image Analyst
Image Analyst on 11 Jul 2021
@Muhammad Basit, I don't understand what you're asking. What sign? The code is the way it should be. If it doesn't work for your data, then give us your data and we'll fix it.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!