Page 1 of 1

a stupid question on fitting two spectra of one sample

Posted: Sun Feb 26, 2023 6:10 pm
by Patto

Hi,
I've been trying to simulate two spectra for the same sample at X band and Q band.
I always run into "First input parameter must be a valid function name or function handle."
Does anyone know any easy way to simulate two spectra?
The code I've been trying to run below:
% Simulate mock X/Q-band data
Sys.lw = [0,1.714];
Exp.mwFreq = 9.409308; %experimental data
Exp.Range = [290 370];
yX = pepper(Sys, Exp, SimOpt);
Sys.lw = [0,1.714];
Exp.mwFreq = 34.067051; %experimental data
Exp.Range = [1140 1260];
yQ = pepper(Sys, Exp, SimOpt);

% Perform Fitting
esfit('mysimfun',[yX(:);yQ(:)],Sys,Exp,Vary,SimOpt,FitOpt)

function y = mysimfun (Sys,Exp,SimOpt)
scale = 1;
y = [yX(:); scale*yQ(:)];
end


Re: a stupid question on fitting two spectra of one sample

Posted: Wed May 10, 2023 10:48 am
by Stefan Stoll

It looks like you are using 5.2.x, right?

I would strongly recommend switching to version 6.

Then the call should be

Code: Select all

data = [yX(:);yQ(:)];
esfit(data,@mysimfun,{Sys,Exp,SimOpt},{Vary},FitOpt)

Note that the first and second input are swapped relative to 5.2.x, and the rest of the inputs are also provided in a slightly different way.


Re: a stupid question on fitting two spectra of one sample

Posted: Mon Jul 17, 2023 6:13 pm
by Patto
Stefan Stoll wrote: Wed May 10, 2023 10:48 am

It looks like you are using 5.2.x, right?

I would strongly recommend switching to version 6.

Then the call should be

Code: Select all

data = [yX(:);yQ(:)];
esfit(data,@mysimfun,{Sys,Exp,SimOpt},{Vary},FitOpt)

Note that the first and second input are swapped relative to 5.2.x, and the rest of the inputs are also provided in a slightly different way.

It always meets an error using version 6, but it works viz verson 5.2.3:
“You provided 7 inputs, but esfit requires 4, 5, or 6.
Examples:
esfit(data, fcn, p0, pvary)
esfit(data, fcn, p0, pvary, Opt)
esfit(data, fcn, p0, lb, ub)
esfit(data, fcn, p0, lb, ub, Opt)”


Re: a stupid question on fitting two spectra of one sample

Posted: Sat Sep 02, 2023 11:22 pm
by Stefan Stoll

Have you tried calling esfit the way I suggested above? There, there are only 5 inputs, and you shouldn't get this error message.

Make sure you are using version 6.0.0-dev.*. You can check by typing easyspin in the command window.