Full Width at Half Max Peaks

77 ビュー (過去 30 日間)
Naif Alsalem
Naif Alsalem 2020 年 11 月 5 日
コメント済み: Image Analyst 2022 年 3 月 10 日
Dear all,
I have 3 peaks close to eachother and I would like to find the FWHM and draw some lines like the graph produced by the Image Analyst here: https://au.mathworks.com/matlabcentral/answers/510144-peak-width-at-half-height
I have loaded my data and normalized already then I utilized this following code (with very slight modification) produced by the Image Analyat here:
% Find the half height - midway between min and max y values.
halfHeight = (min(normy) + max(normy)) / 2;
hold on;
yline(halfHeight, 'Color', 'g', 'LineWidth', 2);
% Find left edge
index1 = find(normy >= halfHeight, 1, 'first');
x1 = x(index1)
line([x1, x1], [0, normy(index1)], 'Color', 'r', 'LineWidth', 2);
text(x1+1, 5, sprintf('x1 = %.2f', x1), 'FontSize', 1, 'Color', 'r');
% Find right edge
index2 = find(normy >= halfHeight, 1, 'last');
x2 = x(index2)
line([x2, x2], [0, normy(index2)], 'Color', 'r', 'LineWidth', 2);
text(x2+1, 5, sprintf('x2 = %.2f', x2), 'FontSize', 1, 'Color', 'r');
% Compute the full width, half max.
fwhm = x2 - x1
text( -0.02688, halfHeight+2, sprintf('width = %.2f', fwhm), 'FontSize', 1, 'Color', 'r', 'HorizontalAlignment', 'center');
caption = sprintf('Full Width, Half Max = %.2f', x2 - x1);
title(caption, 'FontSize', 1);
The "normy" is the y-axis values normalized. The value -0.02688 in the "text" command is the c1 value which is used here in the fwhm equation:
f(x)=a1*exp(-((x-b1)/c1)^2). The produced graph shows the right edge is not accurate and it rather picked up the centre of the peak itself.
Is there anything I am missing here?
Thank you
  2 件のコメント
Sindar
Sindar 2020 年 11 月 5 日
編集済み: Sindar 2020 年 11 月 5 日
Do you have a data point between the peak and the halfmax on that side? The code picks the last point >= the halfmax, which looks like it might simply be the right peak.
If necessary, you could interpolate extra points:
k=10;
xq = linspace(x(1),x(end),length(x)*k)
yq = interp1(x,normy,xq);
Naif Alsalem
Naif Alsalem 2020 年 11 月 5 日
Sindar,
Thank you very much for your answer. It really looks like that it is the last point the code is picking. I was just hoping it picks the half point at that side (right side) just like in the left side.

サインインしてコメントする。

回答 (1 件)

Star Strider
Star Strider 2020 年 11 月 5 日
You have not posted the release you are using, however the Signal Processing Toolbox findpeaks function will return the FWHM for every peak it identifies (that you want it to identify).
  2 件のコメント
Francesco Digeronimo
Francesco Digeronimo 2022 年 3 月 10 日
@Star Strider, would you by any chance know if the function findpeaks could also be used to get the area under each peak at FWHM?
Image Analyst
Image Analyst 2022 年 3 月 10 日
@Francesco Digeronimo if it doesn't mention it int he documentation you'd have to get it manually knowing the left and right location and the signal.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by