%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% A sinple function for determining the full width at half maximum Input: x: the array of x-values f: the array of function values Output: fwhm: FWHM of f in the scale given by x %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0002 % A sinple function for determining the full width at half maximum 0003 % Input: 0004 % x: the array of x-values 0005 % f: the array of function values 0006 % Output: 0007 % fwhm: FWHM of f in the scale given by x 0008 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0009 function FWHM = fwhm(x,f) 0010 if nargin < 2 0011 f = x; 0012 x=[1:length(f)]; 0013 end 0014 f1 = f-0.5*max(f); 0015 ind = find(f1(1:end-1).*f1(2:end) <=0); 0016 FWHM = x(ind(2))-x(ind(1));