I fail to code the backwards substitution

2 views (last 30 days)
I managed to write a code on MATLAB for reducing an augmented matrix using Gauss Elimination, and I got an upper triangle matrix, but I do not know how to code backward substitution. This is how I did the reduction:
function sol = GaussianElimination(A,b)
A = [2 4 1;1 1 2;1 1 -1];
b = [2;2;2];
[m n] = size(A)
[m z] = size(b)
A = [A b];
for i = 2:n
A(i,:) = A(i,:)-(A(i,1)/A(1,1))*A(1,:)
end
for i = 3:n
A(i,:) = A(i,:)-(A(i,2)/A(2,2))*A(2,:)
end

Answers (0)

Community Treasure Hunt

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

Start Hunting!