% Relaxation in NMR Ver. 1.1
% Code by Ali Aghaeifar (ali.aghaeifar@tuebingen.mpg.de)
% Date: 24/11/2014

function [t, M]= relaxation(M0, dW, T1, T2, T)
Landa = 42.576e6 * 2 * pi;
B  = [0, 0, dW*2*pi/Landa]; 
 
[t, M] = ode45(@block, (0:1e-3:T), M0);

% plot3(M(:,1), M(:, 2), M(:,3));
% xlabel('i');
% ylabel('j');
% zlabel('k');
% grid on

    function dM = block(ts, M)
    dM = cross(M, Landa*B)' - [M(1)/T2, M(2)/T2, (M(3) - 1)/T1]';
    end
end



