Back substitution help examining code?
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Sai Sri Pathuri
2020 年 2 月 26 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!