Electropermanent magnets for variable-field NMR