Matrix Representations of Sturm–Liouville Problems with Finite Spectrum