TDMA code for MATLAB
TDMA is a quick Aligorithm for solving AX=b when A is Tridiagonal matrix:
Code:
% Written by Amin ShariatKhah 2012  Shahrood University Of technology there is another version of this code in wikipedia: Code:
function x = TDMAsolver(a,b,c,d) you can find some explanation about TDMA and find this code in C and Fortran90 in : HTML Code:
http://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm 
thank you very much,that is what I need
thank you very much,that is what I need

You're welcome

2D line by line iterative TDMA
hello,
I am working on modelling phase change including the effect of convection in liquid phase. I want to write my program on MATLAB. Actually I am a beginner in MATLAB. I need help to write the 2D line by line TDMA iterative solution of my equations ( 2D transient) Can any one provide me with a code to 2D TDMA line by line iterative algorithm for the solution of 2D discretized equations. Thank you in advance 
I cannot provide a Matlab code, but I can provide some advice.
If your stencil looks like this http://i.imgur.com/0Og2iKV.png, you can treat the W and E values explicitly (use the values from the previous time/iteration step). If you are solving , include the W and E values in your solution vector and fill your matrix with the coefficients of unknowns along a NorthSouth line. You can step W to E in the domain along NS lines. 
2D line by line iterative TDMA
Thank you for your reply,
Actually I have a problem in how to define the temperature field in Matlab code, is it a vector or a matrix?? for example in my 2D grid I have T(1,1) T(1,2) .....T(n,m) When I use A line by line TDMA the pentadiagonal matrix became tridiagonal. I am sweeping from west to east along NS lines so for a determined line ( for a specified n ) I have to calculate all the values of temperature for m going from 2 to m ( for example if n=2 (x direction ) so I calculate T(2,2) T(2,3) T(2,4) T(2,5).....(T2,m) and then I sweep to n=3 ....) . here I don't understand how can I define the temperature field in Matlab ?? 
All times are GMT 4. The time now is 03:27. 