From: Marcio Barbalho on 29 Jan 2010 11:09 Dear friends... how to solve problems like this? dy1/dt = y1*a - y2*b dy2/dt = y1*y2 - c a, b and c are parameters, y(i) are (given) variables. I would like to find the best values for a, b and c in order to fit my data to my model. Thank you.
From: Luca Zanotti Fragonara on 29 Jan 2010 11:27 "Marcio Barbalho" <marciobarbalho(a)yahoo.com> wrote in message <hjv17k$llo$1(a)fred.mathworks.com>... > Dear friends... > > how to solve problems like this? > > dy1/dt = y1*a - y2*b > dy2/dt = y1*y2 - c > > a, b and c are parameters, y(i) are (given) variables. I would like to find the best values for a, b and c in order to fit my data to my model. > > Thank you. So it's an identification problem of a non linear model. I would use fmincon with an ode solver inside your fmincon function, which estimates your cost function. To use ODE: [tsol,y] = ode45(@diffeq,t,ystart,options,a,b,c); function dydt=diffeq(t,y,par_ex) dydt = [y(1)*a - y(2)*b; y(1)*y(2) - c];
From: Jan Simon on 29 Jan 2010 11:33 Dear Marcio! > how to solve problems like this? > > dy1/dt = y1*a - y2*b > dy2/dt = y1*y2 - c > > a, b and c are parameters, y(i) are (given) variables. I would like to find the best values for a, b and c in order to fit my data to my model. 1. Start with an inital guess for [a] and [b]. 2. Then vary both guesses by a certain small step [h]. 3. Now you can calculate the sensitivity of the result to the variation of the input. 4. Modify your [a] and [b] according to this sensitivity such that the difference between the wanted and found solution is decreased (in a matching norm). 5. Go to 2. until the changes in [a] and [b] are smaller than a certain value or any other matching condition is reached. Especially for point 4. there are a lot of different methods, e.g. line search. Choosing a good [h] in step 2. fills chapters and books also. If you want any details, please ask for details. Good luck, Jan
From: Marcio Barbalho on 29 Jan 2010 12:00 Could you please give more details on how to create this code? Many thanks
From: Torsten Hennig on 29 Jan 2010 20:33
> Could you please give more details on how to create > this code? > > Many thanks Couple an ODE-solver and a least-squares solver, e.g. ODE45 and LSQNONLIN. This is the way to solve your problem with least effort. Best wishes Torsten. |