Thanks with the code
Code: Select all
esfit('globalfit',[spec_X(:,2);spec_Q(:,2)]',Sys1,Vary1,Exp,SimOpt,FitOpt);
esfit runs and open the GUI.
But now I get the following error message when trying to start a fit in the GUI:
Reference to non-existent field 'scale'.
Error in globalfit (line 13)
scale = Sys.scale; % custom field for relative scaling
Error in esfit
Error in esfit_simplex
Error in esfit
Error while evaluating UIControl Callback
I get this error message even though I have defined "Sys.scale = 20" (or any other number) in the script.
The code for the user-defined simulation function "globalfit" is defined (in analogy to the example "globally fitting multiple spectra" in the easyspin documentation) as follows:
Code: Select all
function y = globalfit(Sys,Exp,Opt)
% X-band:
Exp.mwFreq = Exp.mwFreq_X; % exact measurement frequency read out via eprload from spectrum file
Exp.nPoints = Exp.nPoints_X; % number of data points read out via eprload from spectrum file
y1 = chili(Sys,Exp,Opt); % row vector y1 with simulated data
% Q-band:
Exp.mwFreq = Exp.mwFreq_Q;
Exp.nPoints = Exp.nPoints_Q;
y2 = chili(Sys,Exp,Opt); % row vector y2 with simulated data
scale = Sys.scale; % custom field for relative scaling
% concatenate the spectra:
y = [y1(:); scale*y2(:)];
So what's the problem? Please help.