%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Matlab lecture 11: Linear algebra with matlab and application %%% to solving coupled linear ODEs %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Suppose we want to solve X_dot = A X, with the following matrix A: A = [1, -1, 0; 1, 2, 1; -1, 1, 0] %and with the collowing initial conditions: X0 = [0.1; -0.1; 0.02] % Let's diagonalize the matrix A: [P,D] = eig(A) %Since X=PY, the initial values in term of Y are: Y0 = inv(P) * X0; %Now, say you want to know X(t) at t=0.3 s for instance: t = 0.3; d = diag(D); % extracts the main diagonal of D Y = Y0 .* exp(d*t); X = P*Y % There you go...