Modelling and compact inversion of magnetic data: a Matlab code