The specific error you've encountered likely comes from the range you've provided with vary being overly large(specifically vary.g). As a result, some of the parameter sets generated from monte-carlo end up being out of the field range you've specified.
In general though, I would say its good practice to adjust your initial parameters to get a reasonably good fit, this also gives you a better idea on the range to vary, then use esfit either with simplex or or levmar to nail down the fit. So do something like this:
Code: Select all
clear, clc, clf
[B,spc,par] = eprload('3Mn_etalon_MX_120_17_10_13.DTA');
B = B/10;
spc=spc/max(spc);
plot(B,spc);
Mn.S = 1/2; %MHz
Mn.Nucs = '55Mn';
Mn.g = 2;
Mn.lwpp = 0.5;
Mn.A = 240; %MHz
Exp.mwFreq = par.MWFQ/10^9;
Exp.Range = [min(B) max(B)];
Exp.ModAmp = 0.5; %mT
Exp.nPoints = length(B);
[b1,sim] = pepper(Mn,Exp);
sim = sim/max(sim);
plot(B,spc,b1,sim)
%%
Vary.g = 0.5;
Vary.lwpp = 0.3;
Vary.A = 50;
esfit(@pepper,spc,Mn,Vary,Exp);
I personally have not had very good luck using any of the minimization methods aside from simplex or levmar.