We characterize under what conditions n×n Hermitian matrices A1 and A2 have the property that the spectrum of costA1+sintA2 is independent of t (thus, the trigonometric pencil costA1+sintA2 is isospectral). One of the characterizations requires the first ⌈2n⌉ higher rank numerical ranges of the matrix A1+iA2 to be circular disks with center 0. Finding the unitary similarity between costA1+sintA2 and, say, A1 involves finding a solution to Lax's equation.