# Computing Eigenvectors in MATLAB

I am assigned to compute eigenvalues and eigenvectors in MATLAB of a 2x2 matrix: $$A = \left( \begin{matrix} 3 &0\\ 4 &5\\ \end{matrix} \right)$$

I know that the textbook's solution states that eigenvalue 3 corresponds to an eigenvector $(1 \; -2)$, and eig 5 corresponds to $(0 \; 1)$.

This is what I do. Why am I not getting the correct eigenvectors?

% Define the matrix
A = [3 0;4 5];

% Find Eigenvalues
E1 = eig(A);

% Display Eigenvalues
disp('Eigenvalues of the matrix A:')
E1

% Determine Eigenvectors
[V,D] = eig(A);

% V1 corresponds to eigenvalue 1 and V2 corresponds to eigenvalue 2
V1 = V(:,1)
V2 = V(:,2)

• A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). There's even syntax highlighting! – Mauro Vanzetto Sep 18 '17 at 10:07
• A tip: You can use MathJax to typeset your mathematical formulas. This will make the question much easier to read. – Mauro Vanzetto Sep 18 '17 at 10:08

## 2 Answers

Eigenvectors are only unique to within a scale factor (can be + or - scale factor).

If $x$ satisfies $Ax=\lambda x$, and hence is an eigenvector of $A$ corresponding to eigenvalue $\lambda$, then any multiple of $x$ also satisfies the equation, and hence is also an eigenvector of $A$ corresponding to eigenvalue $\lambda$.

MATLAB normalizes eigenvectors to have 2-norm equal to 1, but even that leaves a choice of sign.

• Of course, if the scale factor is zero, producing a zero vector, then that satisfies the equation, but is not an eigenvector (which must not be the zero vector). But any eigenvector multiplied by a non-zero scale factor is also an eigenvector. – Mark L. Stone Sep 18 '17 at 2:40

I doubt you're doing anything wrong. Matlab (and LAPACK, the guts underneath Matlab) will normalize eigenvectors to unit length, so you won't get (1,-2) for an eigenvector, you'll get (1,-2)/sqrt(5) instead.