Experimental and numerical study of a magnetic pendulum