Primarily, coupled ordinary differential equations (ODEs) in additive form can be decoupled using the substitution and elimination method (Grade 10 algebra). In this simple system, we can decouple the ODEs simultaneously using the matrix method.
The coupled ODEs
can be expressed in matrix form
and simplified to
.Because of the square matrix property
, we can manipulate the matrix equation to become so that we can solve the following decoupled ODEs
.Method 1: Numerical approach
dx(1) = 5 - 1*x(1) + 2*x(2);
dx(2) = 7 - 2*x(1) + 2*x(2);
[t, x] = ode45(@ode, tspan, xinit);
plot(t, x), grid on, xlabel('Time'), legend('x(t)', 'y(t)')
title('Numerical Solutions')
Method 2: Symbolical approach to obtain the analytical solutions (using @Star Strider's code): ode1 = Dy - Dx == 2 - x
ode1(t) =
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1825537/image.png)
ode2 = 2*Dx - Dy == 3 + 2*y
ode2(t) =
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1825538/image.png)
S = dsolve(ode1, ode2, x(0)==1, y(0)==0)
x(t) = simplify(S.x, 500)
x(t) =
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1825539/image.png)
y(t) = simplify(S.y, 500)
y(t) =
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1825540/image.png)
fplot(x(t), [0 10]), hold on, grid on, ylim([-300, 500])
fplot(y(t), [0 10]), hold off, xlabel('Time'), legend('x(t)', 'y(t)')
title('Analytical Solutions')