Solve two ODE with IVP euler

1 view (last 30 days)
shubham kumar gupta
shubham kumar gupta on 17 Jan 2021
Answered: Sam Chak on 17 Jan 2021
I know how to solve a simple ode using euler but confused with putting initial values and solving them
if I have two ODE
dx1/dt=x1*t+x2
and
dx2/dt=2*x1-x2*t
now I have been given initial values/guess
x1,0=1
x2,0=2
delta(t)=0.0001h
and I need to evaluate this ODE using IVP euler from t=0 to t=1h

Accepted Answer

Sam Chak
Sam Chak on 17 Jan 2021
This is one of several ways to simulate the time-varying dynamics.
tspan = 0:0.0001:1; % simulation time and step size
y0 = [1; 2]; % initial condition
[t, y] = ode45(@(t,y) [t*y(1) + y(2); 2*y(1) - t*y(2)], tspan, y0);
plot(t, y)

More Answers (0)

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!