How to find FWHM from this?

209 visualizaciones (últimos 30 días)
hnn
hnn el 8 de Oct. de 2022
Comentada: hnn el 8 de Oct. de 2022
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.

Respuesta aceptada

Image Analyst
Image Analyst el 8 de Oct. de 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)
  1 comentario
hnn
hnn el 8 de Oct. de 2022
Awesome thank you! That gave me exactly what I needed

Iniciar sesión para comentar.

Más respuestas (1)

Chunru
Chunru el 8 de Oct. de 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
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 comentarios
hnn
hnn el 8 de Oct. de 2022
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 el 8 de Oct. de 2022
If you want the width at mid of max and min. Just add:
power = power - min(power);

Iniciar sesión para comentar.

Categorías

Más información sobre Structures en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by