Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Matlab: 6. HOMEWORK #8 If a matrix A has dimension nxn and has n linearly

ID: 3732530 • Letter: U

Question

Using Matlab:

6. HOMEWORK #8 If a matrix A has dimension nxn and has n linearly independent eigenvectors, it is diagonalizable. This means there exists a matrix P such that P-1AP D, where D is a diagonal matrix, and the diagonal is made up of the eigenvalues of A. P is constructed by taking the eigenvectors of A and using them as the columns of P. Your task is to write a program (function) that does the following . Finds the eigenvectors of an input matrix A Checks if the eigenvectors are linearly independent (think determinant) - if they are not linearly depended, exit the program &display; error . Displays P, P1 and D (if possible) Shows that PDP-1 A Show that your program works with a 3x3 matrix A

Explanation / Answer

Possible solution of this probelm will be follwoing programme.Try to execute and see the result....

A=[5 -2 -2; 7 -4 -2; 3 1 -1] %This matrix is taken as input you can change accordingly

[P,D]=eig(A) %This will generate eigen vectors along with diagonal matrix of Matrix A

[m,n]=size(P)
for i=1:m
for j=1:n
fprintf('%d',P(i,j))
end
end
d=det(P)
if d==0
fprintf('Error!!!')
exit;
end
p_inv=inv(P)
[m1,n1]=size(p_inv)
for i=1:m1
for j=1:n1
fprintf('%d',p_inv(i,j))
end
end
[m2,n2]=size(D)
for i=1:m2
for j=1:n2
fprintf('%d',D(i,j))
end
end
X=P*D*(p_inv) %x will show copy of Matrix A

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote