0
votes

I have to fit experimental data (x, y) with the function g(x)=(A*B*x)/(1+B*x))+K*x+L*x^n.

This is my code:

x=[0;2;4;6;8;10;15;20;25;30;35;40;45;50;55;60;65;70;75;80;85;90];
y=[0.01;0.32;0.76;1.15;1.51;1.83;2.45;3.03;3.6;4.18;4.75;5.30;5.85;6.53;7.25;8.26;9.25;10.46;11.45;13.37;15.75;18.68];
g=fittype('((A*B*x)/(1+B*x))+K*x+L*x^n', 'independent',{'x'}, 'coefficients',{'A','B','K','L','n'});
f=fit(x,y,g,'StartPoint', [53.07, 0.003612, 0.139, 0.0002939, 2.454], 'Lower', [0 0 0.1 0 0 ],'MaxIter',100000);
plot(f)
hold on
scatter(x,y)

The problem is that it throws a figure with a curve which doesn't fit with experimental data.

Can anyone explain to me why ? How do I get a curve which fits with data ?

1
Add more information! It will be easier to help you...ivoruJavaBoy

1 Answers

0
votes

When I fit your posted data and equation with no parameter bounds, a plot of fitted equation vs. raw data gives no visual indication of the problem which you reported. Perhaps the problem is somehow related to the parameter bounds, and if so when you fit without bounds you will have similar results to those I obtained. One of the parameter bounds may be causing the observed difficulty. For comparison, here are the parameter values and fit statistics I obtained when fitting without bounds:

A = -4.6348799797589422E+00
B = -8.5030471461837072E-03
K = -2.3151367681587254E-01
L =  5.1192051372512604E-01
n =  8.5896339221116724E-01

Degrees of freedom (error): 13
Degrees of freedom (regression): 4
Chi-squared: 0.129575842219
R-squared: 0.999684934083
R-squared adjusted: 0.999587990724
Model F-statistic: 10312.051735
Model F-statistic p-value: 1.11022302463e-16
Model log-likelihood: 18.863852459
AIC: -1.540428051
BIC: -1.2931025627
Root Mean Squared Error (RMSE): 0.0848449049798

A = -4.6348799797589422E+00
std err: 2.21395E+00
t-stat: -3.11497E+00
p-stat: 8.20677E-03
95% confidence intervals: [-7.84937E+00, -1.42039E+00]

B = -8.5030471461837072E-03
std err: 1.21952E-07
t-stat: -2.43489E+01
p-stat: 3.13238E-12
95% confidence intervals: [-9.25748E-03, -7.74861E-03]

K = -2.3151367681587254E-01
std err: 4.48642E-01
t-stat: -3.45642E-01
p-stat: 7.35141E-01
95% confidence intervals: [-1.67855E+00, 1.21552E+00]

L = 5.1192051372512604E-01
std err: 3.36712E-01
t-stat: 8.82213E-01
p-stat: 3.93682E-01
95% confidence intervals: [-7.41674E-01, 1.76551E+00]

n = 8.5896339221116724E-01
std err: 7.71803E-02
t-stat: 3.09187E+00
p-stat: 8.57996E-03
95% confidence intervals: [2.58784E-01, 1.45914E+00]

Coefficient Covariance Matrix
[  2.22119894e+02  -5.17965896e-02   8.95871374e+01  -7.83675558e+01
-3.62713522e+01]
[ -5.17965896e-02   1.22351509e-05  -1.99822391e-02   1.74993754e-02
8.05904780e-03]
[  8.95871374e+01  -1.99822391e-02   4.50111094e+01  -3.89773831e+01
-1.86449684e+01]
[ -7.83675558e+01   1.74993754e-02  -3.89773831e+01   3.37814021e+01
1.61229511e+01]
[ -3.62713522e+01   8.05904780e-03  -1.86449684e+01   1.61229511e+01
7.74329075e+00]