ind a nonsingular matrix p such that p-1ap is a diagonal matrix, use sym(a) to get elements of p. in matlab

main.m
A = [a11, a12, a13; a21, a22, a23; a31, a32, a33];  % Define matrix A

[P,D] = eig(sym(A));  % Find eigenvectors and eigenvalues of A

P_inv = inv(P);  % Calculate the inverse of matrix P

D  % The diagonal matrix
P_inv * A * P  % The diagonal matrix P^(-1) * A * P

267 chars
10 lines

related categories

gistlibby LogSnag