Skip to content
Permalink
eb47264c20
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
 
 
Cannot retrieve contributors at this time
18 lines (15 sloc) 545 Bytes
function [x] = solve_tridiag(ud,uo,lo,b)
%Takes the main diagnol of the upper matrix and the off
%diagnol of the lower and upper matrices and the vector b.
%Input - solution for lu_tridiag function
%Output - x vector (Ax = B)
M = zeros(1,length(ud)); % initializing the vector
for n = 1:(length(ud)-1)
M(1)=b(1);
M(n+1)= b(n+1)-(lo(n)*M(n));
end
x=zeros(1,length(ud)); % initializing x vector
for k =(length(ud):-1:2)
x(length(ud))=M(length(ud))/ud(length(ud));
x(k-1)= (M(k-1)-(uo(k-1)*x(k)))/(ud(k-1));
end