Solve two ODE with IVP euler

1 Ansicht (letzte 30 Tage)
shubham kumar gupta
shubham kumar gupta am 17 Jan. 2021
Beantwortet: Sam Chak am 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

Akzeptierte Antwort

Sam Chak
Sam Chak am 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)

Weitere Antworten (0)

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by