EasySpin plots simulation *before* fit, not *after* fit

General forum for EasySpin: questions, how to's, etc.
Post Reply
pyrabbo
Newbie
Posts: 4
Joined: Sat Jan 25, 2020 12:54 pm

EasySpin plots simulation *before* fit, not *after* fit

Post by pyrabbo »

Hi, I'm new to easyspin and having this troubling error on both a PC and mac installation of the latest version of EasySpin 5.2.27 (with Matlab R2019b)

When I attempt to plot my fitted data, it plots only the simulated data *before* the fit. I can't seem to access the X,Y parameters of the fitted data in any format. This same code worked flawlessly with previous versions of Matlab & Easyspin.

Code: Select all

plot (B, spc/max(spc), B, pepper(Sys, Exp, fit1)/max(pepper(Sys,Exp,fit1)))
1) Simulation before fit:
https://ibb.co/2qtXHdq

2) Simulation after fit:
https://ibb.co/t3BLt1x

3) Plot result (wtf?):
https://ibb.co/10YLfVQ

I'd be grateful for any suggestions. Thanks in advance!
Stefan Stoll
EasySpin Creator
Posts: 1050
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: EasySpin plots simulation *before* fit, not *after* fit

Post by Stefan Stoll »

Please post your script, including the data and the start parameters that you use to run esfit.
pyrabbo
Newbie
Posts: 4
Joined: Sat Jan 25, 2020 12:54 pm

Re: EasySpin plots simulation *before* fit, not *after* fit

Post by pyrabbo »

Code: Select all

[B,spc] = textread('myfile.txt');

Code: Select all

Sys.g = [2.2 2.2 2.2];
Sys.S = 3/2;
Exp.Range = [10 490]
Temperature = 15.7;
Exp.mwFreq = 9.630866;
Sys.nPoints = 1024;
Exp.nPoints = 1024;

Code: Select all

Sys.lwpp = [0 8];             
EoverD = 0.33;
D = 40000
Sys.D = [D D*EoverD];
Sys.DStrain = [10000 1];
pepper (Sys,Exp);
Opt.Method = 'matrix';

Code: Select all

Vary.g = [0.3 0.3 0.3];
Vary.lwpp = [12 1];
Vary.D = [10000 1000];
Vary.DStrain = [6000 1];

esfit('pepper',spc,Sys,Vary,Exp);
I run the fitting program with:
Method: Nelder/Mead simplex
Target: data as is
Scaling: scale & quad.
Startpoint: Selected parameter set

Then hit "save parameter set," "export," and I plot it using the "plot" command from the first post.

I also get the "Spectrum exceeds sweep range. Artifacts a upper limit possible." error
Stefan Stoll
EasySpin Creator
Posts: 1050
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: EasySpin plots simulation *before* fit, not *after* fit

Post by Stefan Stoll »

Please post your data file, so we can try to reproduce this.
pyrabbo
Newbie
Posts: 4
Joined: Sat Jan 25, 2020 12:54 pm

Re: EasySpin plots simulation *before* fit, not *after* fit

Post by pyrabbo »

oh sorry, here is the text file.

https://easyupload.io/yzqy8u
Stefan Stoll
EasySpin Creator
Posts: 1050
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: EasySpin plots simulation *before* fit, not *after* fit

Post by Stefan Stoll »

It appears you are including a quadratic background correction in your fit. The spectrum plotted by esfit will include this, and the spectrum simulated with pepper not. Use rescale to include it.
pyrabbo
Newbie
Posts: 4
Joined: Sat Jan 25, 2020 12:54 pm

Re: EasySpin plots simulation *before* fit, not *after* fit

Post by pyrabbo »

i'm not entirely convinced this is only a scaling-issue. i can adjust the scaling in excel, but it still looks nothing like the fitted dataset:
https://ibb.co/F0rWXy0

regardless, how do I include *rescale* in here? i keep getting error messages...
Stefan Stoll
EasySpin Creator
Posts: 1050
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: EasySpin plots simulation *before* fit, not *after* fit

Post by Stefan Stoll »

I would not use lsq2 (scale and quadratic baseline) in esfit in your case. Use lsq0 (scale and shift) or lsq (scale only) instead.

If spc_exp is your experimental spectrum, and spc_sim is the simulated one use,

Code: Select all

spc_sim = rescale(spc_sim,spc_exp,'lsq2')
Then, spc_sim will include an additional quadratic polynomial background that improves the fit with the experimental spectrum.
Post Reply