MATLAB: How to find FWHM in histogram

fwhmhistogram

how can I evaluate the FWHM in a histogram with 2 peaks or more? I couldn'f find a built-in function…
thanks!

Best Answer

Try this (untested):
counts = histcounts(data);
maxCounts = max(counts);
leftBin = find(counts > maxCounts/2, 1, 'first')
rightBin = find(counts > maxCounts/2, 1, 'last')
fwhm = rightBin - leftBin; % Add 1 if you want, depending on how you define width.