lsq1

General forum for EasySpin: questions, how to's, etc.
Post Reply
radovanh
User
Posts: 16
Joined: Thu Jan 19, 2017 8:04 am

lsq1

Post by radovanh »

Hello,
is there possibility to printout after fitting the EPR spectrum with ESFIT also parameters of lsq1 (FitOpt.Scaling = 'lsq1';)?

And also I would like to ask how to directly print to text file info about best fit parameters after finishing ESFIT?
ESFIT print to MATLAB console e.g.
Best-fit parameters:
g: 2.006248
lwpp(2): 0.2198318
A(1): 38.41927
A(2): 133.5821
A(3): 36.86013
Residuals of best fit:
rmsd 0.0795227

I and would like to automatically print it to text file.

Thank you for any hint in advance
Radovan
joscha_nehrkorn
EasySpin Guru
Posts: 32
Joined: Wed Jan 20, 2016 11:35 am

Re: lsq1

Post by joscha_nehrkorn »

You have to run esfit such that it returns the best-fit parameters in a structure.

Code: Select all

bestsys = esfit('pepper',sn,FitSys,Vary,Exp);
The structure bestsys contain the best-fit parameters. The simplest way to store this information is to use the matlab command save. However, this will not generate a textfile but a mat-file (you need matlab to open these files). If you need it in a text file you have to write a loop over all fields of the structure and print them with fprintf.
radovanh
User
Posts: 16
Joined: Thu Jan 19, 2017 8:04 am

Re: lsq1

Post by radovanh »

Thank you for help.
Finally, I solved it with this one line command:
writetable(struct2table(BestSys), 'D:\MATLAB\myfitparam.txt')

which creates txt file with following content:
g,Nucs,A_1,A_2,A_3,lwpp_1,lwpp_2,weight
2.00623559139005,"N,P,H",38.7415138085437,133.047458565127,35.1752243125145,0,0.159081132661415,1

Once more, thank you

Radovan
katarkon
Local Expert
Posts: 193
Joined: Mon Jan 12, 2015 4:01 am

Re: lsq1

Post by katarkon »

I have made a script for visualization of the fitting results some time ago viewtopic.php?f=8&t=311 May be some ideas from it will be useful for solving of your problem.
Post Reply