What does this syntax do in a matrix within a for loop

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)?

回答(1 个)

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.

类别

帮助中心File Exchange 中查找有关 Operators and Elementary Operations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by