Please help, I wrote a matlab code for the Simple Subspace Iteration. But the iteration does not to stop

Here is the algorithm
Start: Choose an initial system of vectors X_{0}
Iterate: Until convergence do,
(a)X_{k}=AX_{k-1}
(b)X_{k}=QR the QR factorization of X_{k} and set X_{k}=Q
Here is my code
function [v,lamda] = SSI(A,tol) n=size(A,1); v=rand(n,1); res=1; while (res > tol) W= A*v; [Q,R]=qr(W); lamda=Q end

 채택된 답변

Sara
Sara 2014년 4월 28일
You have to calculate res in the while loop for it to end at some point.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

2014년 4월 28일

답변:

2014년 4월 28일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by