%% Eigenvalues and Eigenvectors of Matrix
% Use gallery to create a circulant matrix.

A = gallery('circul',3)

%
% Calculate the eigenvalues and right eigenvectors of A.

[V,D] = eig(A)

%
% Verify that the results satisfy A*V = V*D.

A*V - V*D

% Ideally, the eigenvalue decomposition satisfies the relationship. Since eig performs the decomposition using floating-point computations, then A*V can, at best, approach V*D. In other words, A*V - V*D is close to, but not exactly, 0.
% Copyright 2012 The MathWorks, Inc.