3
$\begingroup$

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.9487

I 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$
  • $\begingroup$ @Amzoti tbh, I saw that during my search and I have no idea what that is or what to do with it.... $\endgroup$ – Richard Nov 30 '14 at 18:41
  • 3
    $\begingroup$ How about using sym as in: fgerid.blogspot.com/2009/11/… $\endgroup$ – Amzoti Nov 30 '14 at 18:42
  • $\begingroup$ @Amzoti yep that worked. It still says -1/3 and 1 rather than -1 and 3 but that's good enough. $\endgroup$ – Richard Nov 30 '14 at 19:00
  • 2
    $\begingroup$ Eigenvectors are not unique and they are likely using different algorithms. $\endgroup$ – Amzoti Nov 30 '14 at 20:21
3
$\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$
1
$\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$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.