I'm trying to get the outputs for a QR factorization

3 views (last 30 days)
The for loop only displays one iteration of B and i need many iterations.
A=[8, -3, 0, 2; -9, 4, 5, -7; 6, -2, 2, 4; 5, -1, 7, 10];
for n = 5:1
[Q,R]=qr(A);
B=R*Q;
end
disp(B);

Answers (1)

Walter Roberson
Walter Roberson on 1 May 2017
5:1 is the empty vector. Remember, 5:1 is the abbreviation for 5:1:1 which requests the vector starting at 5 and counting upwards to 1, which is not possible.
If you need to loop in reverse use 5:-1:1
  2 Comments
kevin
kevin on 1 May 2017
I meant to write 1:5 but it still only iterates 1 time and I'm trying to run this code numerouse times to estimate the eigen values.
Walter Roberson
Walter Roberson on 2 May 2017
You are overwriting the same variable each time, so you would not be able to tell it ran the loop multiple times, except by the timing.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!