|
|
Re: nolinear regression model
Posted:
Jul 8, 2008 2:56 AM
|
|
"Miroslav Balda" <balda.nospam@cdm.it.cas.cz> wrote in message <g4uuhm$t79$1@fred.mathworks.com>... : SNIP : > Hi Ender > > Could you send me some of your data? I'll try to solve it. > > Mira
Hi
I decided to show you a solution on a simulated example. Here is the code:
% Ender 2008-07-08 a = 10, b = -8, c = -.2 % Model parameters t = (0:.1:1)'; % should be a column vector f = a + b*(1-exp(t/c)) + .2*randn(size(t)); % Column vector of residuals res = @(x) x(1) + x(2)*(1-exp(t/x(3))) - f; % solve it with rather bad estimate of parameters x0 = [5,3,-.1]; [x,ssq,cnt] = LMFnlsq(res,x0) plot(t,f, t,res(x)+f,'r'), grid
The output from the run has been: >> Ender a = 10 b = -8 c = -0.2000 x = 10.0640 -7.9915 -0.1926 ssq = 0.2140 cnt = 8 You see that after 8 evaluations of function and Jacobin matrix, the solution of the example is close to the initial a, b, and c. Differences are caused by random deviations in the formula for f. Hope it helps. Mira
|
|