write the system in the form Ax = b, then write a MATLAB function that performs
ID: 3600383 • Letter: W
Question
write the system in the form Ax = b, then write a MATLAB function that performs back substitution to solve the system of equations. For this function, think about matrix indices and the pattern involved in back substitution.
The output from the program should be the augmented matrix that contains the upper triangular form of the matrix A and the corresponding vector b and the final solution to the system of equations. The MATLAB script should work for any linear system of equations.Comments your code.
Do not use MATLAB built-in Gaussian elimination functions to solve the system of equations
b – c + d + 2f = 0
2a + 5b – 2c – d + 3e + 6f = 6
a – b – 2d + 6e + 7f = 8
a + b + c – d – e – 6f = 3
3a – 9b + 4c – 5d – e + 2f = -1
-2a – 3b + 3c + 2d + e = 11
Explanation / Answer
Explanation : Take an upper triagular matrix, and take vector b n by 1,then specifiy the deimesions of the array as n.
function x= backSubstitution(u,b,n)
x = zeros(n,1);
for j=n:-1:1
if(u(j,j) == 0) error("Matrix is sigula!"); end;
x(j) = b(j)/u(j,j);
b(1:j-1)=b(1:j-1)-u(1:j-1,j)*x(j);
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.