% This subroutine does the LU decomposition for the % orthogonal collocation method on finite elements. % This version is for a single unknown, giving a block % diagonal matrix with a single entry of overlap. % This subroutine is in the Appendix % of "Nonlinear Analysis in Chemical Engineering". % It assumes diagonal pivoting is OK. % The matrix Aocfe is stored as Aocfe(np,np,ne), where % np is the number of collocation points in one element % and ne is the number of elements. function OCFElud(np,ne) global Aocfe n1 = np - 1; for l=1:ne for k=1:n1 k1=k+1; for i=k1:np s = Aocfe(i,k,l)/Aocfe(k,k,l); Aocfe(i,k,l) = s; for j=k1:np Aocfe(i,j,l) = Aocfe(i,j,l) - s*Aocfe(k,j,l); end end end if l