Dear community,
I would like to fit an solid state EPR spectrum, using a user defined function for simulation with pepper. There are 2 spin Systems: (S =1/2, 4 equivalent N nuclei, axial system) and (S=1/2, 4 equivalent N nuclei, 1 Au nucleus, rhombic system). I found in the EasySpin documentation of esfit how to define user defined functions for constraint fitting:
http://easyspin.org/easyspin/documentat ... #multicomp
This works well for a one component System. When modifying to a 2 component System, I obtain the following error message:
______________________________________________________________
Struct contents reference from a non-struct array object.
Error in Constraints (line 3)
fullSys0.A = [Sys0.A(1,:); Sys0.A(2,:); Sys0.A(2,:); Sys0.A(2,:); Sys0.A(2,:)];
____________________________________________________________________
esfit is defined as:
esfit('Constraints',spc,{Sys0,Sys1},{Vary0,Vary1},Exp,SimOpt,FitOpt);
with the user defined function Constraints.m:
function y = Constraints(Sys0,Sys1,Exp,Opt)
fullSys0 = Sys0;
fullSys0.A = [Sys0.A(1,:); Sys0.A(2,:); Sys0.A(2,:); Sys0.A(2,:); Sys0.A(2,:)];
% Sys0.A is an 2x3 Array with the A tensor of Au (1st row) and N (2nd row) in the struct Sys0.
fullSys0.Nucs = 'Au,N,N,N,N';
fullSys1 = Sys1;
fullSys1.A = [Sys1.A; Sys1.A; Sys1.A; Sys1.A];
fullSys0.Nucs = 'N,N,N,N';
Opt.Method = 'perturb';
[x,y] = pepper({fullSys0,fullSys1},Exp,Opt)
end
I would be pleased, if somebody could give some hints.
Thank you in Forward,
Christoph
esfit userdefined function pepper
Re: esfit userdefined function pepper
When I want to pass multiple systems to a help function, I find it useful to join the Sys and Var structures after they have been defined:
Then, I invoke them as substructures of Sys:
As far as the error is concerned, maybe if you provide the full code and the definitions of Sys.A it would be easier to propose a solution.
Code: Select all
etc
etc
Sys = {Sys1,Sys2};
Vary = {Vary1,Vary2};
esfit('my_func',spc,Sys,Vary,Exp,[],FitOpt);
Code: Select all
y = my_func(Sys,Exp,Opt);
etc
etc
Sys{1,1}.g <--g structure of 1st component
Sys{1,2}.g <--g structure of 2nd component
etc
Re: esfit userdefined function pepper
Hi,
It works now by defining
Sys = {Sys1,Sys2};
Vary = {Vary1,Vary2};
as 1X2 cells and reading out the relevant entries of the structures:
function y = Constraints(Sys,Exp,Opt)
fullSys0 = Sys{1,1};
fullSys0.A = [Sys{1,1}.A(1,:); Sys{1,1}.A(2,:); Sys{1,1}.A(2,:); Sys{1,1}.A(2,:); Sys{1,1}.A(2,:)];
fullSys0.Nucs = 'Au,N,N,N,N';
fullSys1 = Sys{1,2};
fullSys1.A = [Sys{1,2}.A; Sys{1,2}.A; Sys{1,2}.A; Sys{1,2}.A];
fullSys1.Nucs = 'N,N,N,N';
Opt.Method = 'perturb';
[x,y] = pepper({fullSys0,fullSys1},Exp,Opt)
end
It works now!
Thank You very much!
It works now by defining
Sys = {Sys1,Sys2};
Vary = {Vary1,Vary2};
as 1X2 cells and reading out the relevant entries of the structures:
function y = Constraints(Sys,Exp,Opt)
fullSys0 = Sys{1,1};
fullSys0.A = [Sys{1,1}.A(1,:); Sys{1,1}.A(2,:); Sys{1,1}.A(2,:); Sys{1,1}.A(2,:); Sys{1,1}.A(2,:)];
fullSys0.Nucs = 'Au,N,N,N,N';
fullSys1 = Sys{1,2};
fullSys1.A = [Sys{1,2}.A; Sys{1,2}.A; Sys{1,2}.A; Sys{1,2}.A];
fullSys1.Nucs = 'N,N,N,N';
Opt.Method = 'perturb';
[x,y] = pepper({fullSys0,fullSys1},Exp,Opt)
end
It works now!
Thank You very much!