I need to use MATLAB to write this example by Crout factorization method can any
ID: 3282735 • Letter: I
Question
I need to use MATLAB to write this example by Crout factorization method
can anyone help me
r a m ation method PA -LU vnstruct the solution to AX dre A is non-singular matriv tion X = lufact (A, B) A is an N x N non-singular matrix B is an N x I matrix InputA -X is an Nx1 matrix containing the solution to the Output Initialize X,Y, the temporary storage matrix C, and the row taining the solution to the linear system AX-B N N]- size(A); X-zeros(N, 1); Y-zeros(N,1); C-zeros (1,N) R-1:N; %Find the pivot row for column p max1 j]-max(abs(A(p:N,P)); %Interchange row p and J d-R(p) R(p)-RG+p-1); IfA(p,p)--0 A is singular. No unique solution Break end %Calculate multiplier and place in subdiagonal porton ofA For k-p+I:N Mult-A(k,p)/A(p.p); A(k,p)-mult; End End % Solve for Y Y(k)-B(R(k)-AK,Ik-lyyak- end For k-2:NRA 149Explanation / Answer
MATLAB Code of Crout factorization method
function [L,U]=LU_Crout(A,c) %Function to carryout LU factorization using Crout's Algorithm
m=3;
n = 3;
A=[4 2 3; 2 -4 -1; -1 1 4];
c=[7;1;-5];
L=zeros(3,3);
U=zeros(3,3);
L(:,1)=A(:,1);
U(1,:)=A(1,:)/L(1,1);
U(1,1)=1;
for k=2:m
for j=2:m
for i=j:m
L(i,j)=A(i,j)-dot(L(i,1:j-1),U(1:j-1,j))
end
U(k,j)=(A(k,j)-dot(L(k,1:k-1),U(1:k-1,j)))/L(k,k)
end
d(1,1) = c(1,1)/L(1,1);
end
end