% FwdSubDemo script demonstrates forward substitution. % % Usage: >> FwdSubDemo % close all clc % Generate random 6x6 matrix and keep only its lower % triangular part. disp('Lower triangular 6x6 matrix') L = tril(rand(6)) xx = ones(6,1); % Exact solution is vector of ones. disp('Right side vector b') b = L*xx disp('Solution by row-oriented forward substitution') xr = FwdSubRow(L,b) disp('Norm of error vector Computed_x - Exact_x') er = norm(xr-xx,1) disp('Solution by column-oriented forward substitution') xc = FwdSubCol(L,b) disp('Norm of error vector Computed_x - Exact_x') ec = norm(xc-xx,1)