here is my code, and I am able to find the eigenvalue which I am excepted, but not the corresponding eigenvector.
function [ l,x,it ] = powerit( A,x0,N,tol )
A=[1 1 0 0;1 2 0 1; 0 0 3 3;0 1 3 2]
x0=[1;1;0;1]
tol=1e-4
N=25
af=norm(A);
x=x0/norm(x0);
for k=1:N
y=A*x; l=x'*y; if norm(y-l*x)/af < tol it=k; x=y/norm(y); return end x=y/norm(y);
end it=N+1
end
Best Answer