Showing posts with label FWHM. Show all posts
Showing posts with label FWHM. Show all posts

Monday, April 12, 2010

Full width at half maximum

Hi everyone, I have a new reader and we talked about Full Width at Half Maximum - FWHM here (in the comments).

We developed a code for finding the FWHM of a given peak in a function, and now the code will be posted in this post.

function [fwhm_positions, fwhm_values] = fwhm(x, positions)
tp = positions; //assign the peak position into tp

t_aux = 1;
while x(tp) < 2*x(tp + t_aux),
t_aux = t_aux + 1;
end;

fwhm_positions = (tp - t_aux):(tp + t_aux);
fwhm_values = x((tp - t_aux):(tp + t_aux));
endfunction;

t = 1:1000;
m = 350;
s = 180;
x = exp(-(1/(2*s))*(t - m).^2); // 'x' is a gaussian function

plot(t, x);
plot(fwhm_positions, fwhm_values, 'r.-');


Now, look the result following.


Thanks CV, you helped us too much!
God bless you.