Two component fitting
Hi, I am a new user trying to fit two component epr spectra, I used the following code. I think i get the fitting, but i am unable to separate the two component from the fitted data. How can I get the two component graph separately? please help me.
% Load experimental data
[filename,filepath] = uigetfile('*.txt','Open experimental data to fit');
path = [filepath,filename];
[B, spc] =textread(path)
figure;
plot(B, spc);
%%
Sys1.g = [2.0072, 2.0062, 2.0033];
Sys1.A=[6.7 6.7 35];
Sys1.Nucs = '14N';
Sys1.weight =20;
Sys1.lwpp = 0.1; % mT
Sys2.g = [2.0072, 2.0062, 2.0033];
Sys2.A=[6.7 6.7 35];
Sys2.weight = 80;
Sys2.Nucs = '14N';
Sys2.lwpp =0.15; % mT
Sys1.logtcorr =-9.5;
Sys2.logtcorr =-8.4;
Exp.mwFreq = 9.5; % GHz
Exp.Range = [336.7 340.2]; % mT
Exp.nPoints = 2048;
Sys = {Sys1,Sys2};
Vary1.g = [0.009, 0.025, 0.009]; % Check if this g-tensor is correct for your system
Vary1.A = [1.5 1.5 1.5]; % Check if hyperfine values are reasonable
Vary2.g = [0.009, 0.003, 0.009];
Vary2.A=[1.5 1.5 1.5];
Vary1.weight=15;
Vary2.weight =15;
Vary1.lwpp = 0.09; % Ensure line width is set correctly
Vary2.lwpp = 0.09; % Allow more variation for Sys2
Vary1.logtcorr =1;
Vary2.logtcorr =1;
Vary = {Vary1, Vary2}; % Now includes variability for the third system
Options.LLMK = [40000, 18000, 6000, 400]; % Increase the iteration limits
Options.maxIter = 300000; % Increase the max iterations
Options.tol = 1e-01; % Relax tolerance a bit
% Call the fitting function
FitOpt.Method = 'simplex'; % Try a more robust method
SimOpt.Method = 'simplified'; % Switch to simplified method for faster convergence
esfit(spc,@chili,{Sys,Exp,SimOpt},{Vary}, FitOpt);
% Save the fitted spectrum and magnetic field to a file
eprsave('myfile',B,spc,'EasySpin simulation');