How do I make the loop run more than once?

1 view (last 30 days)
kevin
kevin on 1 May 2017
Commented: Walter Roberson on 2 May 2017
The for loop only displays one iteration of B and I need many iterations so I can estimate the eigenvalues.
A=[8, -3, 0, 2; -9, 4, 5, -7; 6, -2, 2, 4; 5, -1, 7, 10];
for n = 1:5
[Q,R]=qr(A);
B=R*Q;
end
disp(B);

Answers (1)

Jan
Jan on 2 May 2017
A = [8, -3, 0, 2; -9, 4, 5, -7; 6, -2, 2, 4; 5, -1, 7, 10];
for n = 1:5
[Q, R] = qr(A);
A = R * Q; % not B = ...
end

Community Treasure Hunt

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

Start Hunting!