MATLAB Answers

Fitting to an intergral

7 ビュー (過去 30 日間)
Jason Ngo
Jason Ngo 2020 年 3 月 27 日
回答済み: Torsten 2020 年 3 月 27 日
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)
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
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 件のコメント



Torsten 2020 年 3 月 27 日
Use "ArrayValued=true" as option in the call to integral.

  0 件のコメント


その他の回答 (0 件)


Community Treasure Hunt

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

Start Hunting!

Translated by