Guassian Function, for loop only runs once???
Show older comments
a=[A,B];
for i=1:4;
a(2,i)=a(2,i)-(a(2,1)/a(1,1)).*a(1,i)
end
This is one of my first lines in my function but I do not know what this for loop only runs once A is a 3X3 matrix and B is a 3X1 which I combined for an augmented matrix
2 Comments
Adam Danz
on 4 Feb 2019
The four-loop definitely runs 4 times.
As evidence, insert this line anywhere inside your for-loop and the iteration number will be displayed in the command window.
fprintf('iteration #%d\n', i)
Only the 2nd row of 'a' will be affected by your code. Perhaps that's causing unexpected results?
Abigail Osborne
on 4 Feb 2019
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements 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!