Page 1 of 1

lsq1

Posted: Thu Apr 06, 2017 9:45 am
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

Re: lsq1

Posted: Fri Apr 07, 2017 1:06 am
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.

Re: lsq1

Posted: Fri Apr 07, 2017 4:28 am
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

Re: lsq1

Posted: Mon Apr 10, 2017 12:42 am
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.