Experimental estimation of the dimension of classical and quantum systems