find a nonsingular matrix p such that p^{-1}ap is a diagonal matrix. in matlab
main.m
% Given matrix aa = [1, 2; 3, 4];
% Compute eigenvalues and eigenvectors[V, D] = eig(a);
% Create nonsingular matrix P using the eigenvectorsP = V;
% Calculate the inverse of PP_inv = inv(P);
% Calculate the diagonal matrix using eigenvaluesD = diag(diag(D));
% Verify the resultresult = P_inv * a * P; % should be a diagonal matrixdisp(result);