So I am trying to get matlab to output the correct eigenvalue/eigenvector of a matrix. The matrix is: \begin{array}{ccc} 0 & 1 \\ -3 & -4 \end{array}
The eigenvalues are: $\lambda_1 = -1, \lambda_2=-3$
Therefore the eigenvector that I calculated and that wolframalpha verifies is: \begin{array}{ccc} 1 & 1 \\ -1 & -3 \end{array}
However, when I run the following matlab code:
A = [0 1; -3 -4;];
[T,lambda] = eig(A)I get the following as the output:
T = 0.7071 -0.3162 -0.7071 0.9487I understand that the ratios are correct (i.e $\frac{-.3162}{.9487}=-3$) but I want it to output the eigenvector as whole numbers like how I calculated above. Is there anyway to do that?
$\endgroup$ 42 Answers
$\begingroup$The eigenvalues that Matlab gives you are normalized to have a magnitude of 1 (i.e. they are all stated as unit vectors). You can prove this to yourself like this:
A = [0 1; -3 -4;];
[T,lambda] = eig(A);
sqrt(sum(T.^2))which gives a vector of 1s.
I'm assuming that the eignvectors you are looking for a normalized to have 1 as the value of their first component. You can scale the Matlab eigenvectors into the form you desire by dividing each vector by it's first element, which is vectorized using the bsxfun function in Matlab:
bsxfun(@rdivide, T, T(1,:))which results in
ans = 1 1 -1 -3 $\endgroup$ $\begingroup$ Based on Amzoti's answer/comment, using the symbolic toolbox you could use the following to get the desired integral solution:
A = sym([0, 1; -3 -4]);
[U,L] = eig(A);
Uint = zeros(size(U));
for i = 1:size(U,2) [~, den] = numden(U(:,i)); mul = 1; for j = 1:numel(den) mul = lcm(mul, den(j)); end Uint(:,i) = U(:,i) * mul;
end
disp(U)
disp(Uint) $\endgroup$