Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Unknown Parameter estimation using fminsearch and ode45 for exp data fitting
Date: Mon, 10 Feb 2014 15:00:18 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 51
Message-ID: <ldapi2$785$1@newscl01ah.mathworks.com>
References: <ldan6o$ifj$1@newscl01ah.mathworks.com> <ldaoc8$cau$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: rubyext-01-ls.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1392044418 7429 172.20.102.177 (10 Feb 2014 15:00:18 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 10 Feb 2014 15:00:18 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 4677174
Xref: news.mathworks.com comp.soft-sys.matlab:808974

Dear Torsten,

yeah, if i am not mistaken, it can be solved easily by introduced integrated eqn and solved using fminsearch. But i do hope to know what is the correct script to solve it using combination of ode45 and fminsearch because i try to make it as a template for my another ode eqn that is much more complicated than this.  could you give me some advise? thank you very much.


"Torsten" wrote in message <ldaoc8$cau$1@newscl01ah.mathworks.com>...
> "PeiYing Ong" wrote in message <ldan6o$ifj$1@newscl01ah.mathworks.com>...
> > dear all, 
> > 
> > I have been struggling on this for weeks and I still cant figure out what is the main problem with my codes. I can solved my ODE equation easily using ode45. but it stuck and it seem like can't be proceed once it combines with the parameter estimation using fminsearch!
> > 
> > Basically, there are 2 constants need to be estimated which is p(1) and p(2). My script codes as follow:
> > 
> > 1st M-file:
> > function F=funeqn(t,x,p)
> > %estimation example p(1)=a,p(2)=b.
> > F=-p(1)*x*log(x/(p(2)));
> > 
> > 2nd M-file:
> > function R2=fun(p)
> > global t x;
> > t=[0;3;6;9;15;18;21;24;27;30;33;39;42;45;48;51;54];
> > [tode,xode]=ode45(@funeqn,t,0.01,[],p);
> > %%Sum least square error
> > xbar=mean(x);
> > deviation= x-xode;
> > SST=dot(xode-xbar,xode-xbar);
> > SSE=dot(deviation,deviation);
> > R2=(1-(SSE/SST))
> > 
> > 3rd M-file:
> > function nonlinearfit
> > global t x;
> > t=[0;3;6;9;15;18;21;24;27;30;33;39;42;45;48;51;54];
> > x=[0;0;1;1;1.66666666666667;2;2.33333333333333;12.6666666666667;13;25;43;53.3333333333333;113.333333333333;155.333333333333;189.666666666667;259.333333333333;312];
> > guess=[.068 358];
> > [p,error]=fminsearch(@fun,guess);
> > R2=error;
> > %
> > figure(1)
> > plot(tode,xode,'-',t,x,'o');
> > ylabel('growth rate');
> > legend('model_Fit','Experimental_data')
> > fprintf('The regression is R^2 = %9.7f.\n',R2)
> > 
> > can anyone give me some suggestions? thanks in advance!
> 
> Your ODE can be integrated analytically. Why don't you use this explicit expression ?
> 
> Best wishes
> Torsten.