ode inside ode ; coupled ode ?
Show older comments
Hi,
my ode requires a solution of another ode. The therm diff(sol.y)/diff(sol.x)/sol.y(end) is needed in the second ode.
for example
function dvdt=myfun(t,v,...)
% Calculating the height of the liquid and its derivative
sol = ode45(f,TSPAN,h,OPTIONS,v,v0,uclose,Au,dw);
h_nm1=h_n;
h_n=sol.y(end);
dh=diff(sol.y)./diff(sol.y);
% my ode MOL discretization calculating the concentration of particles
i=1
dvdt=...
i=2:N-1
dvdt=...
i=N
dvdt=...
Two Questions:
I do not need to solve the first ode always from zero. So i could use the old solution as initial conditions and the old time like TSPAN=[told t] ?
The way i am solving it makes me somehow uncomfortable. I am sure there is a better way. Could i solve both odes at once? But still the second one needs the solution of the first one. So it would be better to set them up as coupled ODES ?
I know you could answer those questions with "yes" or "no", but please comment an that.
Moritz
2 Comments
Moritz
on 13 Aug 2013
RahulTandon
on 30 Jun 2015
Could you please provide the two basic equations, to start with. The approach here is different!
Answers (1)
Torsten
on 30 Jun 2015
Solve the (N+1) ODEs simultaneously in one call to ODE15s:
dv(1)/dt = ...
dv(2)/dt = ...
...
dv(N)/dt = ...
+
dh/dt = ...
Best wishes
Torsten.
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!