How can I fit a curve where integration of a function is involved?

My function is like f1 = integral(@(x1)fun(x1,A,B),0,1000); where "fun" has a exponential term and a "ln" term. A,B are constants which would come out after fitting the curve Is there any way to put this equation in matlab curve fitting tools? If it is possible then how can i call the function "fun"?

2 comentarios

What precisely are you doing?
What are your independent and dependent variables with respect to ‘f1’?
Are you fitting ‘A’ and ‘B’?
f1(m)=integral(@(x1)fun(x1,A,B),0,1000); where fun=(x1,m,A,B); like fun=exp(-A*x^2*ln(B+x))*cos(m*x). I am fitting f1(m) with respect to m. After the fitting the A and B value would come out.

Iniciar sesión para comentar.

Respuestas (3)

function fitting
xdata = [...];
ydata = [...];
fun=@(x,xdata,A,B)exp(-A*x.^2.*log(B+x)).*cos(xdata*x);
fun2=@(y)integral(@(x)fun(x,xdata,y(1),y(2)),0,1000,'ArrayValued',true);
y0=[1 1];
y = lsqcurvefit(fun2,y0,xdata,ydata)
Best wishes
Torsten.
SWAGATA BHUNIA
SWAGATA BHUNIA el 10 de Mzo. de 2016
I am not getting the plot. It is showing that lsqcurvefit stopped because the final change in the sum of squares relative to its initial value is less than the default value of the function tolerance. I have written the plot command as
times = linspace(xdata(1),xdata(end),1000); plot(xdata,ydata,'ko',times,fun2(y,times),'b-')
How can I remove this problem? I am changing the y0 value but it is showing same.
Torsten
Torsten el 11 de Mzo. de 2016
Editada: Torsten el 11 de Mzo. de 2016
Add the lines
ydata_sim = fun2(y);
plot(xdata,ydata,xdata,ydata_sim)
at the end of the code.
Best wishes
Torsten.

Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 7 de Mzo. de 2016

Editada:

el 11 de Mzo. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by