Method for probing the magnetic state of nanomaterials encapsulated in carbon nanotubes