Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab - ADI Method Code

  1. Nov 14, 2009 #1

    I've been having some difficulty with Matlab. I keep getting confused with the indexing and the loops.

    To set up the code, I am trying to implement the ADI method for a 2-D heat equation (u_t=u_xx+u_yy+f(x,y,t)). I have Dirichlet boundary conditions on the left, upper, and lower boundaries, and a mixed boundary condition on the right boundary.

    The coefficient matrix and source vector look okay after the x-direction loop. I have spent well over a 10 hours trying to get it to work.

    Can somebody check the code please?

    Here's the code:


    f, robinbc, and uexact are obtained from separate script files.

    Thank you.
  2. jcsd
  3. Nov 14, 2009 #2
    I finally figured it out... I believe, at least. I'll go ahead and post the code for reference for future visitors who may run into the same issues.


    It seems to converge to second-order accuracy with larger and larger mesh size. Other than the fact the solution is good compared to an exact solution, it seems to follow the behavior of the ADI scheme in that regard.
  4. Nov 16, 2009 #3

    I was wondering if you could repost your code as I having trouble viewing it. I am working on a similar problem, and am stuck on the indexing.

    Thanks a lot.
  5. Nov 29, 2009 #4


    User Avatar

    I would also appreciate if you upload the file again.The link does not work, it says that the file is unavailable.
  6. Jan 7, 2010 #5
    me doing project in ADI method of solving 2d heat equation
    am urgently in need of matlab codes for that.
    Can yu help me
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook