function [D,L,U]=SplitMatrix(A) %Splits the matrix for a manual Jacobi Iteration, where A=D+L+U [m,n]=size(A); D=diag(diag(A)); L=zeros(m,n); %Gets storage ready for L, U (not necessary, but speeds it up) U=zeros(m,n); for j=1:n for k=j+1:n U(j,k)=A(j,k); L(k,j)=A(k,j); end end