How to find FWHM from this?
216 views (last 30 days)
Show older comments
I am very new to Matlab, and am trying to find the FWHM from this curve. I have tried findpeaks, and don't really understand any of it. I have these (time and power) as my variables and have tried but really don't know how to do it.
0 Comments
Accepted Answer
Image Analyst
on 8 Oct 2022
See if this is what you want
halfMaxValue = max(power) / 2; % Find the half max value.
% Find indexes of power where the power first and last is above the half max value.
leftIndex = find(power >= halfMaxValue, 1, 'first');
rightIndex = find(power >= halfMaxValue, 1, 'last');
% Compute the delta time value by using those indexes in the time vector.
fwhm = t(rightIndex) - t(leftIndex)
More Answers (1)
Chunru
on 8 Oct 2022
Your data has no half power points so you cannot find fwhm.
load(websave("fwhmdata.mat", "https://www.mathworks.com/matlabcentral/answers/uploaded_files/1149260/fwhm%20data.mat"))
whos
plot(time, power);
[pmax, imax] = max(power);
hold on
plot(time(imax), pmax, 'ro');
i1 = find(power(imax:-1:1) <= 0.5*pmax, 1, 'first')
i2 = find(power(imax:end) <= 0.5*pmax, 1, 'first')
if ~isempty(i1) & ~isempty(i1)
fwhm = tmax(i2+imax-1) - tmin(imax-i1+1);
else
fwhm = nan;
end
fwhm
8 Comments
Chunru
on 8 Oct 2022
If you want the width at mid of max and min. Just add:
power = power - min(power);
See Also
Categories
Find more on Structures in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!