Fitting function involving an integral



Hello


I have a problem in fitting data with a
function involving an integral.
The function I have is:
G(exdata)=INTEGRAL[((f(1)./0.296).*(((f(3).^2)./(((x+f(4).*exdata(i)-f(2)).^2)+((f(3)).^2))).*((sech((1./(2*0.296)).*x)).^2)))
dx]

where f(i)s are the fitting parameters, x is the variable I
want to integrate over. exdata contains my experimental data.
I defined in an m-file the function in the following way:


function y=fitfunction(f,exdata)
for i=1:length(exdata)
t(i)=quad(@(x)((f(1)./0.296).*(((f(3).^2)./(((x+f(4).*exdata(i)-f(2)).^2)+((f(3)).^2))).*((sech((1./(2*0.296)).*x)).^2))),-15,15,1.0e-10);
y=t';
end

I stress that I wrote exdata(i) and t(i) because exdata is a
vector of several points, and Matlab needs a scalar to
perform the integral. In this way, it performs the integral
for each value of exdata. In this way, the vector y is built.
Then I use the previous function to fit my data by means of
the command: lsqcurvefit(@fitfunctionLorentzian, x0, xdata,
ydata,[],[],options) which appears in an another m-file.

The problem is that when I try to perform the fit, the value
I get for the fitting parameters are completely meaningless.
The experimental data represent a peak, and the Matlab for
some reason is not able at all to recognize even the center
of the peak. And not even the order of magnitude. I do not
know whether I make some mistakes or not. Generally, I got
very good results for the fits thanks to Matlab.
Could someone help me, please?
Thanks a lot for your help.
Raffaello
.



Relevant Pages

  • Re: Help me
    ... exdata contains my experimental data. ... and Matlab needs a scalar to ... Then I use the previous function to fit my data by means of ... I get for the fitting parameters are completely meaningless. ...
    (comp.soft-sys.matlab)
  • Chart add-in?
    ... If there any way (possibly throught an add in?) to fit ... data in a chart to a user defined equation and return ... fitting parameters. ...
    (microsoft.public.excel.charting)