how are elctromagnets similar to other magnets