- #1

- 7

- 0

__Hy, I wonder wich is the good solution for this problem:__

Nonlinear least square problem: function:

**y = x / (a + b.x)**linearization: 1/y = a/x + b substitution: v = 1/y , u = 1/x >> model v = b + a.u

__What we did in school:__

*x = [1 2 4 7]; y = [2 1 0.4 0.1];*

v=1./y;

u=1./x;

n = length(x);

A=[ones(n,1), u']

xbeta=A\v'

Lbeta=xbeta;

beta0=flipud(Lbeta)

beta=fminsearch('kritfun',beta0)

r = [kritfun(beta0) , kritfun(beta)]

v=1./y;

u=1./x;

n = length(x);

A=[ones(n,1), u']

xbeta=A\v'

Lbeta=xbeta;

beta0=flipud(Lbeta)

beta=fminsearch('kritfun',beta0)

r = [kritfun(beta0) , kritfun(beta)]

__+ kritfun.m__

*function z=kritfun(beta)*

a=beta(1);

b=beta(2);

x = [1 2 4 7];

y = [2 1 0.4 0.1];

error = y - x./(a + b*x );

z = sum((error .^2 ));

a=beta(1);

b=beta(2);

x = [1 2 4 7];

y = [2 1 0.4 0.1];

error = y - x./(a + b*x );

z = sum((error .^2 ));

__in ML we get__:*xbeta =*

7.3658

-8.1692

beta =

1.0e+014 *

-8.2085

4.1043

r =

11.0600 4.1700

7.3658

-8.1692

beta =

1.0e+014 *

-8.2085

4.1043

r =

11.0600 4.1700

__but when I try in Curve Fitting tool too check the soulution , I get something else ..according to this video:__

*too call CF I typed to prompt >>*

**cftool**__When I try this I get the same number like in the Curve fitting tool , the a,b parameters is my beta(1),beta(2) and the SSE number is my r(2) ..what was same when I tried this:__

*x = [1 2 4 7];*

y = [2 1 0.4 0.1];

%u = 1./x; %these u and v I dont use it...but I didnt know when not using substituion is correct the beta and r(2) , but when I didnt use I get same numbers lik in the Curve Fitting tool

%v = 1./y;

n = length(x);

X = [ ones(n,1), x'];

btr = X\y'

beta0 = flipud(btr)'

beta = fminsearch('mnsNLcFUN',beta0)

r = [mnsNLcFUN(beta0), mnsNLcFUN(beta)]

y = [2 1 0.4 0.1];

%u = 1./x; %these u and v I dont use it...but I didnt know when not using substituion is correct the beta and r(2) , but when I didnt use I get same numbers lik in the Curve Fitting tool

%v = 1./y;

n = length(x);

X = [ ones(n,1), x'];

btr = X\y'

beta0 = flipud(btr)'

beta = fminsearch('mnsNLcFUN',beta0)

r = [mnsNLcFUN(beta0), mnsNLcFUN(beta)]

__+ mnsNLcFUN.m function is:__

*function z=mnsNLcFUN(beta)*

a=beta(1);

b=beta(2);

x = [1 2 4 7];

y = [2 1 0.4 0.1];

error = y - x./(a+b.*x);

z = sum((error .^2 ));

a=beta(1);

b=beta(2);

x = [1 2 4 7];

y = [2 1 0.4 0.1];

error = y - x./(a+b.*x);

z = sum((error .^2 ));