Hamiltonian Structure of Equations Appearing in Random Matrices