Link Search Menu Expand Document

Finite-Difference Models of the Heat Equation


Overview

This page has links to MATLAB code and documentation for finite-difference solutions the one-dimensional heat equation

where is the dependent variable, and are the spatial and time dimensions, respectively, and is the diffusion coefficient.

The zip archive contains implementations of the Forward-Time, Centered-Space (FTCS), Backward-Time, Centered-Space (BTCS) and Crank-Nicolson (CN) methods. In addition a more flexible version of the CN code is provided that makes it easy to solve problems with mixed boundary conditions, for example,

where and are parameters of the boundary condition and can be time-dependent. All of the codes in this archive use a uniform mesh and a uniform diffusion coefficient, .


Code archives

The following zip archives contain the MATLAB codes

Code documentation

Forward-Time, Centered-Space in one space dimension

Backward-Time, Centered-Space in one space dimension

Crank-Nicolson in one space dimension

Implementing Boundary Conditions for Crank-Nicolson in one space dimension