%FORWARD Forward substitution for lower triangular systems % using a row-oriented implementation. % 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(1) = b(1)/A(1,1); for i = 2:1:m, % i starts at 2, end at 4, w/ steps of 1 x(i) = (b(i)-A(i,1:i-1)*x(1:i-1)')/A(i,i); end x = x'; % convert and display result as column