This and a lot of other useful formulations are given in the book "Finite Element Analysis using Matlab". It is by a Korean author, I don't recollect the name. It is a very good reference book. You can also refer "The Finite Element Method in Engineering" by S.Rao. It has some formulations too.
H. Iyer