Question:
How to solve 1st Order System of Differential Equations in MATLAB?
Answer:
System of Differential equations can be solved symbolically in MATLAB by using built-in command "dsolve"
clear all; clc; close all syms x(t) y(t) z(t) dx = diff(x,t); dy = diff(y,t); dz = diff(z,t); eqn1 = dx == 2*x + y + z; eqn2 = dy == x + 2*y + z; eqn3 = dz == -2*x + -2*y + z; sol = dsolve([eqn1 eqn2 eqn3],t); x = sol.x y = sol.y z = sol.z
OUTPUT
x = C3*((exp(2*t)*sin(3^(1/2)*t))/4 + (3^(1/2)*exp(2*t)*cos(3^(1/2)*t))/4)
- C2*((exp(2*t)*cos(3^(1/2)*t))/4 - (3^(1/2)*exp(2*t)*sin(3^(1/2)*t))/4) - C1*exp(t) y = C1*exp(t) - C2*((exp(2*t)*cos(3^(1/2)*t))/4 - (3^(1/2)*exp(2*t)*sin(3^(1/2)*t))/4)
+ C3*((exp(2*t)*sin(3^(1/2)*t))/4 + (3^(1/2)*exp(2*t)*cos(3^(1/2)*t))/4) z = C2*exp(2*t)*cos(3^(1/2)*t) - C3*exp(2*t)*sin(3^(1/2)*t)
0 Comments