Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [x, y, u, l]=crout(A, B)
- n=size(A,1)
- A(1,2:n)=A(1,2:n)/A(1,1)
- for j=2:n,
- for k=2:j,
- v=A(j,1:k-1)
- w=A(1:k-1,k)
- A(j,k)=A(j,k)-v*w
- end,
- v=A(j,1:j-1)
- for k=j+1:n,
- w=A(1:j-1,k)
- if A(j,j)==0 then
- error("nilai x tidak terdefinisi karena pembaginya 0(nol)")
- end
- A(j,k)=(A(j,k)-v*w)/A(j,j)
- end
- end,
- l=tril(A)
- u=triu(A,1)+eye(n,n)
- y=l\B
- x=u\y
- mprintf("nilai x dari persamaan Ax=B adalah")
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement