How to use one ode45 to solve another?
Show older comments
I have the following for my first ODE:
t0=0; tf=7;
y0=[0 0 0.332]';
[t,y]=ode45('ydot',[t0 tf],y0);
'ydot' is shown below:
function xdot = ydot(t,y)
xdot = zeros(3,1);
xdot(1) = y(2);
xdot(2) = y(3);
xdot(3) = -0.5*y(1)*y(3);
end
I now have a separate set of equations, where I need y from the initial solution.
function zdot = gdot(t,g)
zdot = zeros(2,1);
zdot(1) = g(2);
zdot(2) = -0.5*Pr*y(1)*g(2);
end
The second ode45 I need to solve is below.
t0=0; tf=7; Pr=0.6;
%y0=[0 0 0.332]';
%[t,y]=ode45('ydot',[t0 tf],y0);
g0=[0 0.332*Pr^(1/3)]';
[t,g]=ode45('gdot',[t0 tf],g0);
Any help is greatly appreciated.
Accepted Answer
More Answers (0)
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!