tor, 02 07 2009 kl. 22:36 +0200, skrev Autiwa:
> I think that the last 3 mail (this one count) were only in private
> conversation

Ohh, I didn't notice. I'm CC'ing the list.

> Here is the program with comments in english, maybe less complete, and
> with english error, because I talk easier in french...

Thanks

> I have also added the licence.

You have added:

%## This program is public domain. (GPL)

I hate to be focused on boring license stuff, but we need this to be
correct. The GPL is different from the public domain. So, either put it
in the public domain or release it under the GPL. You have to decide
which you prefer.

Autiwa has suggested that this function goes in the 'signal' package. I
don't really have an opinion on this. What does the rest of the people
on this list think?

Søren
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Function that return the full width at half maximum
%## This program is public domain. (GPL)
% x: define a list of abscisses. If this doesn't exist, the first test create a list that will contain a list of indices to allow the function to return a width that will be in fact a difference between two indices
% f: data of the function from wich we want the fwhm
% In addition, the function will return a warning if the fwhm doesn't exist, and return 0 as fwhm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function FWHM = fwhm(x,f)
if nargin < 2
	f = x;
	x=[1:length(f)];
end

[fmax,ifmax]=max(f);
f_renorm = f-0.5*fmax;
ind = find(f_renorm(1:end-1).*f_renorm(2:end) <=0);%if the product is negative, this means that tha "half-mawimum" is between theses two values
if length(ind) == 2
%we make a linear regression between the two values to get a more precise estimation of the fwhm. 
	x1=(0.5*fmax-f(ind(1)+1))*(x(ind(1)+1)-x(ind(1)))/(f(ind(1)+1)-f(ind(1)))+x(ind(1)+1);
	x2=(0.5*fmax-f(ind(2)+1))*(x(ind(2)+1)-x(ind(2)))/(f(ind(2)+1)-f(ind(2)))+x(ind(2)+1);
	FWHM=x2-x1;
else
	warning('FWHM is undefined, check if there is an impulsion. FWHM is set to 0')
	FWHM=0;%fwhm is set to 0 if it doesn't exist, to avoid errors in the rest of the programme. The warning is here to tell to the user that there is a problem.
end
------------------------------------------------------------------------------
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to