How to find FWHM from this?

조회 수: 206 (최근 30일)
hnn
hnn 2022년 10월 8일
댓글: hnn 2022년 10월 8일
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.

채택된 답변

Image Analyst
Image Analyst 2022년 10월 8일
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)
  댓글 수: 1
hnn
hnn 2022년 10월 8일
Awesome thank you! That gave me exactly what I needed

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Chunru
Chunru 2022년 10월 8일
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
Name Size Bytes Class Attributes M 384x2 6144 double cmdout 1x33 66 char data 384x1 3072 double index1 384x1 3072 double index2 384x1 3072 double power 384x1 3072 double time 384x1 3072 double
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')
i1 = 0×1 empty double column vector
i2 = find(power(imax:end) <= 0.5*pmax, 1, 'first')
i2 = 0×1 empty double column vector
if ~isempty(i1) & ~isempty(i1)
fwhm = tmax(i2+imax-1) - tmin(imax-i1+1);
else
fwhm = nan;
end
fwhm
fwhm = NaN
  댓글 수: 8
hnn
hnn 2022년 10월 8일
Your method did not work but I used a different function which gave me the correct FWHM value which also matches my python answer, as well as matching the physical beam size of the telescope used to gather this data. Thanks for your super super super helpful reply! Have a nice day
Chunru
Chunru 2022년 10월 8일
If you want the width at mid of max and min. Just add:
power = power - min(power);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by