Page 1 of 1

Error using sparse

Posted: Thu Jan 28, 2016 8:00 am
by AndyB
Hi,

I don`t know whether it is a Matlab or an easyspin problem, but when I try to simulate spin systems with a lot of identical nuclei, I get the following error message:

Error using sparse
Index into matrix must be positive.

Error in garlic

Error in garlic

Error in garlic

Error in esfit

Error in esfit_simplex

Error in esfit

Error while evaluating UIControl Callback
The given example is from a esfit simulation, but (basically) the same error occurs without the esfit function. An example for a simulation that triggers this error message is:

clear
[B,spc80] = eprload('N:\Projektübersicht\Projekt 4 Elektrolyse in der EPR-Zelle\Beckradikal\tert-NMepyAzin\tert NAzapz 091215\AB_tertNmepzazin_rt_modamp05_sample1_3');
C = (B)./10;

s80 = spc80;
Sys.Nucs = '14N,14N,1H,1H,1H';
Sys.n = [2 2 2 2 6]
Sys.g = [2.004];

A_N1 = [3.18]; % in MHZ
A_N2 = [10.97];
A_H1 = [7.60];
A_H2 = [9.06];
A_H3 = [12.14];
A_H4 = [0.2];

Sys.A = [A_N1;A_N2;A_H1;A_H2;A_H3];

Sys.lwpp = [0.0 0.00156];

Exp = struct('Range', [min(B) max(B)]*0.1,'mwFreq',9.85184,'Harmonic',1,'ModAmp',0.03);
%
Vary.g = [0.0004];
Vary.A = [2;2;2;2;2];
Vary.lwpp = [0.01 0.04];

SimOpt.Method = 'perturb';
%SimOpt.Method = 'matrix';
%
% Calling the fitting function
FitOpt.Method = 'simplex fcn'; % simplex algorithm, integrals of spectra
%
esfit('garlic',spc80,Sys,Vary,Exp,SimOpt,FitOpt);

Re: Error using sparse

Posted: Thu Jan 28, 2016 8:13 am
by Matt Krzyaniak
That's not quite a bug. That error is a result of transitions being outside the field range. Try removing the range parameter and letting ES calculate the field range it needs initially and then adjust either your experimental field range or g-value.

It is something needs a more informative error message.

Re: Error using sparse

Posted: Thu Jan 28, 2016 9:36 am
by Stefan Stoll
Matt's workaround works, but this is a bug. garlic should not throw an error with out-of-range lines. It should just disregard these lines and issue a warning.

The bug is fixed in 5.0.17, which is available from the website now.