Explicit solutions of Schr\"odinger and KdV equations in terms of square roots of the generalised matrix eigenvalues