function I = hotspin_I( sx, sy, sz, phi)
% returns the matrix I for given sensor position

% define the radius
R = 0.15;

% vector from sensor to specimen
r = [sx-R*cos(phi), sy-R*sin(phi), sz];

% distance between specimen and sensor
abs_r = norm( r);

A = zeros( 3, 3);
% frist row
A(1,1) = 2*r(1)^2-r(2)^2-r(3)^2;
A(1,2) = 3*r(1)*r(2);
A(1,3) = 3*r(1)*r(3);
% second row
A(2,1) = A(1,2);
A(2,2) = 2*r(2)^2-r(1)^2-r(3)^2;
A(2,3) = 3*r(2)*r(3);
% third row
A(3,1) = A(1,3);
A(3,2) = A(2,3);
A(3,3) = 2*r(3)^2-r(2)^2-r(1)^2;

B = [cos(phi) sin(phi) 0; sin(phi) cos(phi) 0; 0 0 1];
I = A*B/abs_r^5*(1e-7/4/pi);