Page 1 of 1

Error using esfit "Too many output arguments"

Posted: Thu Jan 25, 2024 6:22 pm
by konyenwe@unr.edu

Please help.
im trying to export my simulated data,However, I'm running into " Error using esfit
Too many output arguments"

see my code below

clear,clc,clf

[B,spc] = eprload('6_AminoBTR_30_08_23.DTA');
plot(B,spc);

Exp.mwFreq = 9.369752;
Exp.Range = [324.935 344.925]; % mT
Exp.nPoints = 2000; %numel(B)
%Exp.ModAmp = 0.1;
Exp.Temperature = 298;

% Set up spin system with starting parameters
Sys.g = 2.0036;
Sys.S = 1/2;
Sys.Nucs = '14N, 14N, 14N';
Sys.A = [21.5, 14.8, 13.7]; %MHz
Sys.lwpp = [0.35 0.15];

% Set up Vary structure with all parameters that can be varied
Vary.g = 0.002;
Vary.lwpp = [0.02 0.05];
SysVary.A = [5, 5, 5];
Vary.A = [2, 2, 2];

%[B,spc1] = garlic(Sys,Exp);
%plot(B,spc1,'r')
%plot (B,spc/max(spc),'b',B,spc1/max(spc1),'r');

%esfit(spc,@garlic,{Sys,Exp},{Vary})

[fitparams,spc] = esfit(spc,@garlic,{Sys,Exp},{Vary});
npoints = numel(spc);
B = linspace(Exp.Range(1),Exp.Range(2),npoints);
data = [B(:) spc(:)];
save('2.txt','data','-ASCII');


Re: Error using esfit "Too many output arguments"

Posted: Mon Jan 29, 2024 4:39 am
by katarkon

Only one structure fit is returned by esfit().


Re: Error using esfit "Too many output arguments"

Posted: Tue May 07, 2024 8:59 pm
by SpinMeRightRound

Only one structure is returned by the new esfit() function, but in the previous version it returned two. It would be nice to have some explanation on how to map the old outputs onto this new single structure for backwards compatibility... I'm having the same issue as the original poster here.

New function:
fit = esfit(data,fcn,p0,lb,ub,FitOpt)
Old function:
[bestsys,bestspc] = esfit(simfunc,expspc,Sys0,Vary,Exp,SimOpt,FitOpt)

It's a pain that they've changed both the order of inputs and their names (possibly their actual content too) and then also reduced the outputs down to a single structure. I can't find any guide on how to change code from the old easyspin to this new definition, ended up finding this thread when I searched for the "too many output arguments" esfit() error. I can't understand why they would break backwards compatibility so badly with this update and then make the update mandatory too with an expiry date on the old easyspin.

EDIT:
I've now found the migration page that outlines these changes and giving some guidance on how to edit the function call: https://easyspin.org/easyspin/documenta ... n5to6.html

bestspc now seems to be fit.fitraw as far as I can tell, and bestsys seems to be fit.pfit. I'll edit this again as I confirm further.