Here's a possible implementation in MATLAB to solve a 2D PDE using Implicit Euler in time and Central Differencing in space with a Jacobi Solver:
main.m1777 chars52 lines
This code initializes the physical parameters, constructs a grid, defines the initial and boundary conditions and then enters a loop where the Implicit Euler method is used to solve the PDE system. In each time step a coefficient matrix and RHS vector are put together to be used in a Jacobi solver to update the temperature matrix. Finally, the results are plotted with a contourf plot. The code outputs plots of the temperature at 0, 1, 2, 5, 10, and 100 seconds.
gistlibby LogSnag