Fitting to an intergral
3 views (last 30 days)
Show older comments
I am trying to fit a set of data to an integral with the following code but I get an error message. The parameters I am trying to obtain is x(1),x(2), and u, from xdata and ydata. Thanks.
fun= @(x, xdata) (1-((6*x(1))/(pi*sqrt(x(2)))))*integral(@(u) ((exp(-(xdata))*((u*cos(u)-sin(u))^2))/((u^2)*(((u^2)*(sin(u))^2)+(x(2))*(((x(1))/(x(2)))*(u*cos(u)-sin(u))+sin(u))^2))),0,Inf)
x0=(1,1)
lsqcurvefit(fun, x0, xdata, ydata)
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix.
To perform elementwise multiplication, use '.*'.
Error in @(u)((exp(-(xdata))*((u*cos(u)-sin(u))^2))/((u^2)*(((u^2)*(sin(u))^2)+(x(2))*(((x(1))/(x(2)))*(u*cos(u)-sin(u))+sin(u))^2)))
Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 83)
[q,errbnd] = vadapt(@AToInfInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Error in
@(x,xdata)(1-((6*x(1))/(pi*sqrt(x(2)))))*integral(@(u)((exp(-(xdata))*((u*cos(u)-sin(u))^2))/((u^2)*(((u^2)*(sin(u))^2)+(x(2))*(((x(1))/(x(2)))*(u*cos(u)-sin(u))+sin(u))^2))),0,Inf)
Error in lsqcurvefit (line 213)
initVals.F = feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:});
Caused by:
Failure in initial objective function evaluation. LSQCURVEFIT cannot continue.
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!