On page 9 of this pdf describing the finite difference formulation for the heat equation, there is a convenient tridiagonal matrix equation to represent equation 17 (which is on page 8). This represents the finite difference solution for 1D space heat conduction over time. However, the extension into 2D space would make this equation not applicable because there would be 2 more terms added for the y-dimension. I visualized this as the $(1-2r)$ term being changed to $(1-4r)$ and then surrounded on all 4 sides by $r$, so not only left and right but also into and out of the page. And then the $\phi$ term is no longer a vector but represents a 2D sheet of temperature values.
From what I can find, it seems that using tensor math would be the way to properly extend this equation into 2D, but I don't have a full grasp of it yet.
My question is, given my limited understanding of tensors:
How would I (1) organize a tensor equation that would properly collect the 5 terms in the 2D heat equation and (2) create a Matlab implementation of the tensor equation ?