%Inputs: A matrix, b matrix, initial x guess, relaxation, maximum % iterations, tolerance percentage %Outputs: Solution vector, Error vector function [x e] = Lyn_sys_solver(A,b,x,w,maxiter,es) %First normalize the matrix such that all the diagonals are equal to 1. for i=1:length(A) b(i)=b(i)/A(i,i); diag=A(i,i); for j=1:length(A) A(i,j)=A(i,j)/diag; end end iter=0; %keeps track of the number of iteration till convergence maxerr=1; %Maximum loop error, =1 initially %iterate unless error is small enough or number of iteration reached while (maxerr > es && iter