mom dipole calculation using Matlab