a stupid question on fitting two spectra of one sample

General forum for EasySpin: questions, how to's, etc.
Post Reply
Patto
Newbie
Posts: 9
Joined: Sun Feb 26, 2023 5:36 pm

a stupid question on fitting two spectra of one sample

Post 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

Attachments
Co_sup_superoxo_HOTf_XQ.m
(1.4 KiB) Downloaded 497 times
Stefan Stoll
EasySpin Creator
Posts: 1050
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

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

Post 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.

Patto
Newbie
Posts: 9
Joined: Sun Feb 26, 2023 5:36 pm

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

Post 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)”

Stefan Stoll
EasySpin Creator
Posts: 1050
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

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

Post 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.

Post Reply