A variational approach for solving an inverse vibration problem