Fitting an exponential function: Setting options?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Caroline Otto
el 15 de Feb. de 2021
Comentada: Caroline Otto
el 16 de Feb. de 2021
Hello,
I would like to fit a custom specific equation and get an error message. My code is as follows:
T_K = [250.150000000000 253.150000000000 263.150000000000 273.150000000000 283.150000000000 293.150000000000 303.150000000000 313.150000000000 323.150000000000 333.150000000000 343.150000000000 353.150000000000 363.150000000000 373.150000000000 383.150000000000 393.150000000000 403.150000000000 413.150000000000 423.150000000000 433.150000000000 443.150000000000 453.150000000000 463.150000000000 473.150000000000 483.150000000000 493.150000000000 503.150000000000 513.150000000000 523.150000000000 533.150000000000 543.150000000000 553.150000000000 563.150000000000 573.150000000000 583.150000000000 593.150000000000 603.150000000000 613.150000000000]'
d = [985 983 976 969 962 955 948 940 933 926 919 912 904 897 890 882 875 867 859 852 844 836 828 820 812 803 795 786 777 768 759 750 740 730 720 710 699 688]'
f = fittype('A/(B * exp(1+ (1 - T_K/C)^D))',...
'dependent',{'d'},'independent',{'T_K'},...
'coefficients',{'A','B','C','D'});
fit2 = fit(T_K, d, f);
The error I get is in the fit function: [fitobj, goodness, output, convmsg] = iFit( xdatain, ydatain, fittypeobj, ...
My idea was that it could be a mathematical problem with the exponential function. After having read this I tried to set some options (lower bounds, where I was not sure about the order:
options = fitoptions('A/(B * exp(1+ (1 - T_K/C)^D))', 'Lower', [0 Inf Inf 1]);
), but it was without success. Does anybody has an idea about what is wring or the problem could be?
4 comentarios
Respuesta aceptada
Walter Roberson
el 15 de Feb. de 2021
Editada: Walter Roberson
el 15 de Feb. de 2021
options = fitoptions('A/(B * exp(1+ (1 - T_K/C)^D))', 'Lower', [0 Inf Inf 1]);
You set the lower bounds for B and C to infinity?? You divide by C so if C is infinite T_K/C would be sign(T_K)*0
If T_K/C > 1 then 1-T_K/C would be negative, and negative ^D would be complex if D is not an integer. So you need to ensure T_K/C <= 1 so T_K <= C and C should have a lower bound of max(T_K)
6 comentarios
Alex Sha
el 16 de Feb. de 2021
Editada: Alex Sha
el 16 de Feb. de 2021
As commented by David, if you don't drop the B or A, there will be multi-solutions, with the different combinations of A and B, but unique of C and D:
1:
Root of Mean Square Error (RMSE): 1.0064732367416
Sum of Squared Residual: 38.4935582985301
Correlation Coef. (R): 0.999934086786684
R-Square: 0.99986817791792
Parameter Best Estimate
---------- -------------
a -46890.8524606817
b -5.63376277792465
c 1128.65575737085
d -0.508557122720511
2:
Root of Mean Square Error (RMSE): 1.0064732367416
Sum of Squared Residual: 38.4935582985303
Correlation Coef. (R): 0.999934086786694
R-Square: 0.99986817791794
Parameter Best Estimate
---------- -------------
a 103527.516316089
b 12.4384487994102
c 1128.6557688586
d -0.508557130714601
3:
Root of Mean Square Error (RMSE): 1.0064732367416
Sum of Squared Residual: 38.4935582985303
Correlation Coef. (R): 0.999934086786667
R-Square: 0.999868177917885
Parameter Best Estimate
---------- -------------
a 17590.6485257921
b 2.11345146634875
c 1128.65575372825
d -0.508557120581391
...
If drob B, the fitting equation becomes: y = A/(exp(1+ (1 - x/C)^D));
There will be an unique result:
Root of Mean Square Error (RMSE): 1.00647323674159
Sum of Squared Residual: 38.4935582985297
Correlation Coef. (R): 0.999934086786666
R-Square: 0.999868177917884
Parameter Best Estimate
---------- -------------
a 8323.18547243371
c 1128.6557657083
d -0.508557129233705
While If drob A, the fitting equation becomes: y = 1/(B * exp(1+ (1 - x/C)^D));
There will also be an unique result:
Root of Mean Square Error (RMSE): 1.0064732367416
Sum of Squared Residual: 38.4935582985304
Correlation Coef. (R): 0.999934086786664
R-Square: 0.999868177917879
Parameter Best Estimate
---------- -------------
b 0.000120146307262581
c 1128.65577814606
d -0.508557138276278
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!