What does this syntax do in a matrix within a for loop
Show older comments
for i = 1:n-1
a = A(i+1:n,i)/A(i,i); %this gives us the coefficient for row operations
A(i+1:n,:)=A(i+1:n,:)-a*A(i,:); %performs row operations
b(i+1:n,:)=b(i+1:n,:)-a*b(i,:);
end
QUESTION: what is A from 1+1:n, what does that do? how is it different from A(i+1,i)?
Answers (1)
Mubashar Sarfraz
on 30 Aug 2020
0 votes
i+1:n is basically taking rows of the matrix A from i+1 (if i=4, 4+1:n where n i max rows) to the last row. In the later A(i+1,i) is taking only a single row i.e. i+1, not the range of rows (i+1:n) as in the first one.
Categories
Find more on Operators and Elementary Operations 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!