The get most experience from where they are assigned (not the depth chart, but their actual position assignment - because that is what they are focusing on during practice) but they also gain experience for every play they are on the field, whether that is their assigned position or not. The in-game experience will not overcome their position assignment, however, so it is always best to keep them assigned at the position you intend to play them the most.