On the stability of a nonlinear nonhomogeneous multiply hinged beam