I'm trying to get the outputs for a QR factorization
3 views (last 30 days)
Show older comments
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);
1 Comment
Walter Roberson
on 2 May 2017
Duplicated by later https://www.mathworks.com/matlabcentral/answers/338276-how-do-i-make-the-loop-run-more-than-once which also has answers.
Answers (1)
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
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.
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!