Skip to content
Permalink
c625f3cd70
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
@akm13021
Latest commit fc517f1 Mar 29, 2017 History
1 contributor

Users who have contributed to this file

32 lines (23 sloc) 561 Bytes
function [ud,uo,lo] = lu_tridiag(e,f,g)
%Initialize ud,uo,lo
ud = zeros(length(f), 1);
uo = zeros(length(f)-1, 1);
lo = zeros(length(f)-1, 1);
%Set lo,uo,ud
lo = g;
uo(1) = g(1);
ud(1)=f(1);
%Define K
constK = 2;
while constK <= length(f)-1
lo(constK-1) = e(constK-1)/(ud(constK-1));
uo(constK) = g(constK);
ud(constK) = f(constK)-(lo(constK-1)*uo(constK-1));
constK = constK + 1;
end
lo(constK-1) = e(constK-1)/(ud(constK-1));
ud(constK) = f(constK)-(lo(constK-1)*uo(constK-1));
%define mat
e = [1;2;3;4]
f = [1;2;3;4;5]
g = [1;2;3;4]