Back substitution help examining code?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am examining this code for performing back substitution on naive gaussian elimination, and I can't seem to figure out where the x(j) is defined at? Or what exactly it's suppose to be prior to finding the solution x. I know that x is our solutions / solution vector to the system of equations when performing naive gaussian elimination. But I am not sure what exactly the value of a(i,j) * x(j) is at this step; is our solution vector x just suppose to be all zeros?? I am just not following how the solution vector is used in this step. Thanks for the help.
for i = n : -1 : 1
for j = i+1 : n
b(i) = b(i) - a(i,j)*x(j);
end
x(i) = b(i)/a(i,i);
end
0 Kommentare
Antworten (1)
Sai Sri Pathuri
am 26 Feb. 2020
Consider the system of equations as Ax = B where A is the coefficient matrix and B is the constant matrix.
In your code, the matrices a,b correspond to the matrices A, B after Gaussian elimination. For i = n, the value of j is n+1. Hence, the code inside second for loop is not executed. When j = n (the code inside second for loop run for the first time), the value of x(j) is defined as
x(j) = x(n) = b(n)/a(n,n);
And the remaining indices (1:n) of x are set to zero. The values of x for index < n is obtained by using the previous index value. For example, x(n) is used in the computation of x(n-1).
0 Kommentare
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!