how to solve matrix form differential equations using ODE45?

17 visualizaciones (últimos 30 días)
yonghyeok lee
yonghyeok lee el 27 de Abr. de 2021
Editada: Jan el 27 de Abr. de 2021
The equation is as above.
The initial values are X0 , Y0 = 30
Time range is 1 to 1000s
How should I write the code?
a,b are constants.
  2 comentarios
James Tursa
James Tursa el 27 de Abr. de 2021
Is the left hand side supposed to simply be a1*X' for the first equation and b1*Y' for the second equation?
yonghyeok lee
yonghyeok lee el 27 de Abr. de 2021
a_1 , b_1 is constants.
The Equation can be expressed
X' means dx/dt
Y' means dy/dt

Iniciar sesión para comentar.

Respuesta aceptada

Jan
Jan el 27 de Abr. de 2021
Editada: Jan el 27 de Abr. de 2021
y0 = [30; 30];
tspan = [1, 1000];
[t, y] = ode45(@YourODE, tspan, y0);
plot(t, y);
function dy = YourODE(t, y)
a1 = 2; % set accordingly
a2 = 3;
b1 = 4;
b2 = 5;
X = y(1);
Y = y(2);
dy = [-X / a1 + Y / a1 + a2 / a1; ...
X / b1 - Y / b1 + b2 / b1];
% Or:
% dy = [(-X + Y + a2) / a1; ...
% ( X - Y + b2) / b1];
% Or:
% dy = [-1/a1, 1/a1; 1/b1, -1/b1] * y + [a2/a1; b2/b1];
end

Más respuestas (0)

Categorías

Más información sobre Numerical Integration and Differential Equations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by