Prev: Script for automatic research in NIST database
Next: ode45: tspan with same end points affecting results
From: Vyjayanthi A on 14 Mar 2010 20:51 Hi, Can any one explain how can I use fminsearch and ode functions in the same m-file. I have to solve nonlinear equations (which is 6 equations with 6 unkowns) ,then the values I obtain from the above equations will be used in the differential equations. As these equations are in the loop, for the second iteration the values from the differential equation has to be used in nonlinear equations. Can any one please help me where to define fminsearch in this kind of program. example: for i==1:100 x0=1; nonlinear equations, a=P+exp(b)+a^3; b=a+lob(b)+x; differential equations, dx/dt=a+b^2; dP/dt=1+exp(a) end 'P' , 'x', 'a','b',values changes for every iteration and the values obtained from the differential equations has to be used in the nonlinear equations. I am trying to solve from the past 1 week. Any kind of help is highly appreciated. Thank you
From: Derya on 17 Mar 2010 15:38
Hello Vyjayanthi, Do you really want to solve the nonlinear equations and differential equations separately? Will the following technical note about how to solve differential-algebraic equations interest you? http://www.mathworks.com/support/tech-notes/1500/1510.html#dae If your answer is no, read on ... If I understood it correctly, you want to solve the nonlinear equalities for a and b given P and x. Then you want to feed a and b into the ODE's and integrate them until a (given) final time to obtain P and x for the next iteration. I don't see any objective function here in this problem, so I suppose you want to use FSOLVE (not fminsearch) to solve the nonlinear equations. See http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/fsolve.html for details. I hope this helps. Regards, Derya "Vyjayanthi A" <vinzav(a)gmail.com> wrote in message <hnk09o$oi2$1(a)fred.mathworks.com>... > Hi, > Can any one explain how can I use fminsearch and ode functions in the same m-file. > I have to solve nonlinear equations (which is 6 equations with 6 unkowns) ,then the values I obtain from the above equations will be used in the differential equations. > As these equations are in the loop, for the second iteration the values from the differential equation has to be used in nonlinear equations. > Can any one please help me where to define fminsearch in this kind of program. > > example: > > for i==1:100 > x0=1; > nonlinear equations, > a=P+exp(b)+a^3; > b=a+lob(b)+x; > differential equations, > dx/dt=a+b^2; > dP/dt=1+exp(a) > end > 'P' , 'x', 'a','b',values changes for every iteration and the values obtained from the differential equations has to be used in the nonlinear equations. > > I am trying to solve from the past 1 week. > Any kind of help is highly appreciated. > Thank you |