esfit error line 130 using custom function

General forum for EasySpin: questions, how to's, etc.
Post Reply
dgagnon
Newbie
Posts: 3
Joined: Thu Mar 26, 2015 11:54 am

esfit error line 130 using custom function

Post by dgagnon »

I wrote a custom function that outputs a vector of residuals from experimental - simulated for a dozen or so spectra. I'm trying to use esfit to minimize this vector from my function, but keep getting an error.
Specifically:
Error using ~=
Too many input arguments.

Error in /home/derek/Documents/MATLAB/easyspin/easyspin/esfit.p>esfit (line 130)
Output from function is [x,y] = myfunction(Sys,Exps,Opt)
Providing esfit('myfunction',thegoal,Sys,Vary,Exps,Opt) where 'thegoal' is a vector of zeros of equal length and dimensions as y.

Any help with what is causing the error at line 130 of esfit would be greatly appreciated. I can attach a test data set, script, and the function if helpful.
Stefan Stoll
EasySpin Creator
Posts: 1047
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: esfit error line 130 using custom function

Post by Stefan Stoll »

Are you using an array of experiments structures? The line in esfit that causes the error is

Code: Select all

  if Exp.nPoints~=numel(ExpSpec)
If you use an array of structures in Exp, this will give the error you observe.
dgagnon
Newbie
Posts: 3
Joined: Thu Mar 26, 2015 11:54 am

Re: esfit error line 130 using custom function

Post by dgagnon »

You are correct.

So the correct way to do this is to make the parameter(s) I want to vary an array instead of having an array of structures, i.e. do Exp.Field = [350, 351, 352, 353...]. Then per iteration of my custom function create a structure input that salt will be happy with, i.e. NewExp.Field = Exp.Field(i)?

EDIT: So implementing that got me one line further.
Error using esfit (line 131)
Exp.nPoints is 1024, but the spectral data vector is 1 long.
I think I know what to do from here, though. Will post a reply if I get stuck again. Thank you for the help!
Post Reply