411 REFERENCE · Wikibooks
Linear Algebra and the C Language/a0nu
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
__NOTOC__
You can observe in these two examples that the eigenvectors are indeed orthogonal to each other, and that they have the same length and therefore normalized.
Calculate and draw the eigenvectors of a 2x2 matrix
Copy/Paste into the octave window
% Matrix 2x2 -------------
clear, clc
A = [3 4;
4 2]
% Eigenvectors, Eigenvalues
[Evectors,Evalues] = eigs(A);
color1 = 'r' ; % red
color2 = 'k' ; % black
% Plot Eigenvectors
figure(1), clf
plot([0 Evectors(1,1)],[0 Evectors(2,1)],color1)
hold on
plot([0 Evectors(1,2)],[0 Evectors(2,2)],color2)
legend({'v_1';'v_2'})
axis([-1 1 -1 1])
axis square
%%
Calculate and draw the eigenvectors of a 3x3 matrix
Copy/Paste into the octave window
% Matrix 3x3 ---------------------
clear, clc
B = [ 1 3 5 ;
3 2 4 ;
5 4 3 ]
% Eigenvectors, Eigenvalues
[Evectors,Evalues] = eigs(B);
color1 = 'r' ; % red
color2 = 'k'; % black
color3 = 'b' ; % blue
% Plot Eigenvectors
figure(1), clf, hold on
plot3([0 Evectors(1,1)],[0 Evectors(2,1)],[0 Evectors(3,1)],color1)
plot3([0 Evectors(1,2)],[0 Evectors(2,2)],[0 Evectors(3,2)],color2)
plot3([0 Evectors(1,3)],[0 Evectors(2,3)],[0 Evectors(3,3)],color3)
legend({'v_1';'v_2';'v_3'})
axis([-1 1 -1 1 -1 1])
axis square
rotate3d on
%%