How do I make the loop run more than once?
1 view (last 30 days)
Show older comments
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);
2 Comments
KSSV
on 2 May 2017
Your A is fixed, how you expect B to change? You are running loop five times and every time you get the same Eigenvalues.
Answers (1)
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
0 Comments
See Also
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!