%% magdip.m calculates the magnetic field (T) for a offset dipole
%% magnetic field for the given poitnts of interest.

function bf=magdip(dismat,latmatm)

% dismat = radial distance (km)
% latmatm = magnetic latitude (rads)
% bf = magnetic field (T)

re=6371;                                               %Earth radi (km)
bo=30.4e-6;                                            %equatorial magnetic field (T)
bf=bo*(re./dismat).^3.*sqrt(1+3*sin(latmatm).^2);      %magnetic field at point of interest (T)
