function U=tridag(a,b,c,r); % % | b1 c1 0 ... | % | a2 b2 c2 0 | % A= | 0 a3 b3 c3 0 |; A*U=r; % | ... | Solve for U when A and r are given, % | 0 0 aN bN | and A is tridiagonal. if nargin<4 disp('needs a, b, c and r as inputs.') end n=length(b); if length(a)==n-1 a=[0 a]; elseif length(a)==n a(1)=0; end if length(b)~=length(r) disp('forcing vector must have same dimesion as matrix.') end if length(c)