Exporting data

General forum for EasySpin: questions, how to's, etc.
Post Reply
domika1416
Newbie
Posts: 2
Joined: Thu Nov 24, 2022 4:31 am

Exporting data

Post by domika1416 »

Hello, I have performed a least-squares fitting successfully but I am not able to export simulated spectra in ascii. All I get is an experimental spectrum. I have studied exporting section in documentation. There is my code below. I would appreciate any help.
clear,clc
[B,spc] = textread('D:\Dominika sym EPR\1,4dirad119K.txt','%f %f');
plot(B,spc)
%%
Sys = struct('S',1,'g',2.00254,'HStrain',[51.5527 158.536 87.7031],'D',[190.928, -4.24281], 'weight',1);
Sys1 = struct('S',1/2,'g',2.00338,'lwpp',[0.602027 0.34], 'weight', 0.0354022);
Exp.mwFreq = 9.644;
Exp.Range = [min(B/10) max(B/10)];
Exp.nPoints=length(B);
FitOpt.Scaling='lsq0';
FitOpt.Method='levmar fcn';
Opt.Method='perturb';
FitOpt.TolFun=1e-7;
FiOpt.TolStep=1e-8;
Vary.g=(0.01);
Vary.HStrain=[50 50 87];
Vary.D = [80 30];
Vary1.g=(0.01);
Vary1.lwpp = [0.03 .02];
Vary1.weight = 1;
esfit('pepper',spc,{Sys,Sys1},{Vary, Vary1},Exp,Opt,FitOpt);
%%
plot(fit1.fitSpec);
eprsave('fit1',B,spc,'EasySpin simulation');
%%
data = [B(:) spc(:)];
save('fit1.txt','data','-ascii');

DanielKlose
User
Posts: 18
Joined: Thu Jun 09, 2022 5:22 am

Re: Exporting data

Post by DanielKlose »

Dear Dominika,

for me in EasySpin version 6.0.0-dev.48 the following code works:
(note that I had to comment out the experimental file as I didn't have it, but using the simulation by pepper (line 21) instead).

It saves both a DSC/DTA format spectrum as well as the spectrum in ascii format.
Hope that help you, otherwise feel free to ask again.

Code: Select all

clear,clc
% [B,spc] = textread('D:\Dominika sym EPR\1,4dirad119K.txt','%f %f');
% plot(B,spc)
%
Sys = struct('S',1,'g',2.00254,'HStrain',[51.5527 158.536 87.7031],'D',[190.928, -4.24281], 'weight',1);
Sys1 = struct('S',1/2,'g',2.00338,'lwpp',[0.602027 0.34], 'weight', 0.0354022);
Exp.mwFreq = 9.644;
Exp.Range = [0 1000]; %[min(B/10) max(B/10)];
Exp.nPoints=1024; %length(B);
FitOpt.AutoScale=1;
FitOpt.Method='levmar fcn';
Opt.Method='perturb';
FitOpt.TolFun=1e-7;
FiOpt.TolStep=1e-8;
Vary.g=(0.01);
Vary.HStrain=[50 50 87];
Vary.D = [80 30];
Vary1.g=(0.01);
Vary1.lwpp = [0.03 .02];
Vary1.weight = 1;
[x,y] = pepper(Sys,Exp);
esfit(y,@pepper,{Sys,Exp,Opt},{Vary},FitOpt);
%%
% Here save fit in esfit GUI, which generates variable fit1
%%
plot(x,fit1.fit);
eprsave('fitSpec',x,fit1.fit,'EasySpin simulation',9.644);
%
data = [x' fit1.fit];
save('fitSpec_ascii.txt','data','-ascii');
domika1416
Newbie
Posts: 2
Joined: Thu Nov 24, 2022 4:31 am

Re: Exporting data

Post by domika1416 »

Dear Daniel,
I have solved my problem thanks to your comment. Thank you very much! ;)

Post Reply