% Rayleigh quotient iteration

function [v,lambda] = rq_iter(A,v,N)

lambda = v'*A*v;
[m,m1] = size(A);

for k=1:N
    
    w = (A-lambda*eye(m)) \v;
    v = w/norm(w);
    lambda = v'*A*v;
    
end
