How do I make the loop run more than once?

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

Your A is fixed, how you expect B to change? You are running loop five times and every time you get the same Eigenvalues.

Sign in to comment.

Answers (1)

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

Categories

Find more on Linear Algebra in Help Center and File Exchange

Asked:

on 1 May 2017

Commented:

on 2 May 2017

Community Treasure Hunt

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

Start Hunting!