Matrix solution of periodic mathieu equations