From: Piter_ on 21 Apr 2010 10:51 Hi all. I try to estimate parameters by fitting data to model. I have this functions: _______________________________________________ function [sse param]=cox_model_fit(t,dy,param,conc0) dyy=cox_cyt_dis_dt(t,param,start); sse=norm(dyy-dy) _______________________________________________ function [dy]=cox_cyt_dis_dt(t,param,start) very long one for reaction simulation _______________________________________________ t - time dy - concentration changes. conc0 - initial concentrations. param0 - initial guess for estimation of parameters run command like this: global t,dy, conc0 param = fminsearch(@cox_model_fit,param0,options) how can I do it without use of global variables? Thanks. Petro
From: Alistair Templeton on 21 Apr 2010 12:01 > _________________________________________ > function [sse param]=cox_model_fit(t,dy,param,conc0) > dyy=cox_cyt_dis_dt(t,param,start); > sse=norm(dyy-dy) > > _______________________________________________ > function [dy]=cox_cyt_dis_dt(t,param,start) > very long one for reaction simulation > > global t,dy, conc0 > param = fminsearch(@cox_model_fit,param0,options) > > how can I do it without use of global variables? > I'm not familiar with fminsearch, but it seems like any variables that cox_cyt_dis_dt changes should be returnable?
From: John D'Errico on 21 Apr 2010 12:17 Piter_ <x.piter(a)gmail.com> wrote in message <2de9d013-ebd1-45db-acf4-15bac9e919da(a)z3g2000yqz.googlegroups.com>... > Hi all. > I try to estimate parameters by fitting data to model. > I have this functions: > _______________________________________________ > function [sse param]=cox_model_fit(t,dy,param,conc0) > dyy=cox_cyt_dis_dt(t,param,start); > sse=norm(dyy-dy) > > _______________________________________________ > function [dy]=cox_cyt_dis_dt(t,param,start) > very long one for reaction simulation > > _______________________________________________ > t - time > dy - concentration changes. > conc0 - initial concentrations. > param0 - initial guess > for estimation of parameters run command like this: > > global t,dy, conc0 > param = fminsearch(@cox_model_fit,param0,options) > > how can I do it without use of global variables? By passing them in as arguments, using an anonymous function. Change your functions like this... _______________________________________________ function [sse param]=cox_model_fit(t,dy,param,conc0,start) dyy=cox_cyt_dis_dt(t,param,start); sse=norm(dyy-dy); _______________________________________________ function [dy]=cox_cyt_dis_dt(t,param,start) % very long one for reaction simulation _______________________________________________ Finally, here is your call to fminsearch... param = fminsearch(@(param) cox_model_fit(t,dy,param,conc0,start),param0,options) HTH, John
|
Pages: 1 Prev: Kalman Estimator Structure Next: hydraulic valve modelling |