%BACKWARD Backward substitution for upper triangular systems % Written by on function x = forward( A, b ) [m,n] = size(A); if m~=n, % check if # rows ~= # columns in A error('The input matrix, A, is not a square matrix.'), end x(m) = b(m)/A(m,m); for i = m-1:-1:1, % i starts at 2, end at 4, w/ steps of 1 x(i) = (b(i)-A(i,i+1:m)*x(i+1:m)')/A(i,i); end x = x'; % convert and display result as column