
T=100;         %  temperature in K, needed for el. B.f.
sweep=[9.398]
%wn=2*pi*10.705*B0*1e6;  %  MHz * 2*pi; for protons 42.576 should be put in

wm=2*2*pi*263.45*1e9;        %  microwave freq.
w1=2*pi*8.5*1e5;         %  MW-amplitude


DD=2*pi*0*1e6;         % electronic coupling
% relaxation times
T1ea=4*60e-6;
T2ea=4*0.770e-6;

T1eb=60e-6;
T2eb=0.770e-6;

T1n=2; %changed from before
T2n=1e-3;

Je=2*pi*800*1e6;
B0=18.840;  % B0 in Tesla, needed only for the el. B.f.
Azz=2*pi*0.08*1e6;         %  HFI, H_zz(max)

dt=1*1e-10;
N=400000
% settings for time-dependence
wmas=2*pi*8*1e3;        % MAS frequency

Na=str2num(getenv('Na')); %orientations
Nb=str2num(getenv('Nb')); %orientations
Ng=str2num(getenv('Ng')); %orientations
Ia=str2num(getenv('Ia')); %orientations
Ib=str2num(getenv('Ib')); %orientations
Ig=str2num(getenv('Ig')); %orientations

%Nf=length(B0);
%FD=zeros(Nf,4);
            
for k=1:length(B0)
wn=2*pi*42.576*B0(k)*1e6; %  MHz * 2*pi; for protons 42.576 should be put in
    magn=MfromT(B0(k),T,wn,wm,w1,wmas,Azz,DD,T1ea,T2ea,T1eb,T2eb,T1n,T2n,dt,N,Ia,Ib,Ig,Na,Nb,Ng,Je);
%    plot(magn(:,1),magn(:,2),magn(:,1),magn(:,3),magn(:,1),magn(:,4));
filename=[num2str(Ia) '_' num2str(Ib) '_' num2str(Ig) '_',num2str(sweep(k)),'.dat'];
    save(filename,'magn','-ASCII');
%FD(k,1)=B0(k);
%FD(k,2)=magn(N,2);
%FD(k,3)=magn(N,3);
%FD(k,4)=magn(N,4);
%end
end

%       end
%    end
%end

%save fieldsweepdata.dat FD -ASCII   
quit
