Filter löschen
Filter löschen

lsqcurvefit fitting not good

6 Ansichten (letzte 30 Tage)
Zuyu An
Zuyu An am 17 Okt. 2019
Bearbeitet: Alex Sha am 22 Okt. 2019
>> xdata = ...
[0.005 0.01 0.015 0.02 0.025 0.03 0.035 0.04 0.045 0.05 0.055 0.06 0.065 0.07 0.075 0.08];
ydata = ...
[-1.5641 4.331 10.226 10.328 10.43 9.2075 7.9845 6.9538 5.9227 4.7857 3.6488 2.1603 0.67176 0.22867 -0.21442 -0.10787];
fun = @(x,xdata)x(1)+x(2).*sqrt(x(3)./((2.*pi.*x(4).*(xdata+x(5))).^3)).*exp(-x(3).*((x(4).*(xdata+x(5))-x(6)).^3)./(2.*x(4).*(xdata+x(5)).*x(6).^2));
x0 = [0,8,0.9,13,0.01,0.9];
x = lsqcurvefitlsqcurvefit(fun,x0,xdata,ydata)
options = optimoptions('lsqcurvefit','Algorithm','levenberg-marquardt');
lb = [];
ub = [];
times = linspace(xdata(1),xdata(end));
plot(xdata,ydata,'ko',times,fun(x,times),'b-')
legend('Data','Fitted exponential')
title('Data and Fitted Curve')
it should mindestens so:
but in my Matlab it is so:
what should i do? and where am i wrong?

Akzeptierte Antwort

Star Strider
Star Strider am 17 Okt. 2019
Choose different values for ‘x0’.
I used these:
x0 = [-2.6; 17; 0.7; 7; 0.0001; -0.7; 0.7];
to get this result:
x =
-4.324990458427486
29.118149115959035
0.816104607520526
6.992507999448133
0.003331267566044
-0.774459180826721
0.700000000000000
and this plot:
#lsqcurvefit fitting not good.png
I began with a random vector, and used fminsearch to produce the new ‘x0’ vector. It gave a good fit after about 10 initial starts. A better approach would have been to use the ga funciton.
  11 Kommentare
Zuyu An
Zuyu An am 21 Okt. 2019
I am sorry to ask you again, but my probleme seems still not solved. I submit a new question, Could you please help me?
Star Strider
Star Strider am 21 Okt. 2019
I posted an Answer to your new Question.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Alex Sha
Alex Sha am 18 Okt. 2019
Bearbeitet: Alex Sha am 22 Okt. 2019
whether fminsearch or lsqcurvefit in Matlab use local optimization algorithms, it is why the initial start values are so important, unfortunately, guessing good initial start values is nightmare for most of users, although GA toolbox in Matlab use global algorithm, but the effect of GA in Matlab is far below expectations。The follow results are calculated from one of other software by using global optimization, no need to guess initial start values:
Root of Mean Square Error (RMSE): 0.448475537821338
Sum of Squared Residual: 3.21808492838621
Correlation Coef. (R): 0.993866542618332
R-Square: 0.987770704536117
Adjusted R-Square: 0.98588927446475
Determination Coef. (DC): 0.987770704536117
Chi-Square: 0.0996829655505242
F-Statistic: 161.541718751279
Parameter Best Estimate
---------- -------------
x1 -4.32518017924354
x2 1.5161832530864
x3 0.816035356312747
x4 0.139454519659979
x5 0.00333139106331274
x6 -0.015446312666105

Kategorien

Mehr zu Historical Contests finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by