function ret = magneticFieldForMOT(this, r) switch this.SimulationMode case '2D' ret = zeros(1,4); alpha = this.MagneticGradient; ret(1) = r(3)*alpha; ret(2) = 0; ret(3) = r(1)*alpha; ret(4) = sqrt(ret(1)^2+ret(2)^2+ret(3)^2); case '3D' % Development in progress end end