I am receiving a similar error:
Brace indexing is not supported for variables of this type.
Error in esfit
Error in untitled (line 76)
esfit(spc, @pepper, Sys1, Vary1); % Fitting function call
this is the code I am working with:
clear, clc, clf
%%
[B,spc] = eprload('AG21_PFLAE23_hv_D4SAM_40K_3mW_3G.DSC');
[B,spccav] = eprload('AG_buffer_40K_3mW_3G.DSC');
spc1 = spc - spccav;
base0 = spc1(1);
spc2 = spc1 - base0;
plot(B,spc2)
% Experimental parameters
Exp.mwFreq = 9.378; % from par.MWFQ
Exp.Range = [min(B)/10,max(B)/10];
Exp.nPoints = numel(spc2);
%% Define Spin-System For Simulation
Sys1.S = [1/2];
Sys1.g = [2.0075 2.0015 2.00];
Sys1.lw = [1.0];
Sys1.Nucs = '1H, 1H, 1H';
Sys1.A = [-15 -105 -50; -20 -90 -50; 80 85 100]; % MHz
Sys1.AFrame = [0 120 0; 120 0 0; 40 0 0]*pi/180;
Sys1.HStrain = [10 10 10];
Sys1.weight = 0.9;
Sys2.S = [1/2];
Sys2.g = [2.0075 2.0015 2.00];
Sys2.lw = [1.0];
Sys2.Nucs = '2H, 2H, 2H';
Sys2.A = [-15 -105 -50; -20 -90 -50; 80 85 100]/6.514; % MHz
Sys2.AFrame = [0 120 0; 120 0 0; 40 0 0]*pi/180;
Sys2.HStrain = [10 10 10];
Sys2.weight = 0.1;
Opt.Method = 'perturb2'; % Second-order perturbation theory.
% Speeds ups your simulation considerably whith some loss of accuracy.
[Bsim, spcsim1] = pepper(Sys1,Exp); % simulation of cw solid-state EPR
specsim1 = rescale(spcsim1, min(spc2), max(spc2));
[Bsim, spcsim2] = pepper(Sys2,Exp); % simulation of cw solid-state EPR
specsim2 = rescale(spcsim2, min(spc2), max(spc2))
specsim3 = specsim1 + specsim2;
plot(B,spc2,'-k', Bsim*10,specsim3,'-r');
%% Define Varying Parameters for Fitting
Vary1.g = [0.002 0.002 0.002]; % g-values for the fit
Vary1.lwpp = [0.2]; % Linewidth parameters for the fit
Vary1.A = [5]; % Hyperfine coupling parameters for the fit
% Define Simulation and Fitting Options
SimOpt.Method = 'perturb'; % Perturbation method
FitOpt.Scaling = 'maxabs'; % Scaling method for fit
FitOpt.Method = 'simplex fcn'; % Fitting method (simplex)
% Ensure 'Sys1' is a struct with the required fields
Sys1.S = [1/2]; % Spin value
Sys1.g = [2.0075 2.0015 2.00]; % g-tensor values
Sys1.lw = [1.0]; % Linewidth
Sys1.Nucs = '1H, 1H, 1H'; % Nuclei involved
Sys1.A = [-15 -105 -50; -20 -90 -50; 80 85 100]; % Hyperfine interaction (MHz)
Sys1.AFrame = [0 120 0; 120 0 0; 40 0 0]*pi/180; % A-frame parameters (converted to radians)
Sys1.HStrain = [10 10 10]; % Hyperfine strain
Sys1.weight = 0.9; % Weight for this system
% Now call esfit function
esfit(spc, @pepper, Sys1, Vary1, fit0pt); % Fitting function call
%% Plotting the Output of Fitting
figure
plot(fit1.expSpec);
hold on
plot(fit1.fitSpec, 'g');
%% Export Data, Sim, and/or Fit
data = [B(:) spc2(:) specsim1(:)];
xlswrite('20240515_EpeE_SAM_hv_sim',data);
thanks for the help!