Multifrequency esfit errors

General forum for EasySpin: questions, how to's, etc.
Post Reply
AMullen
User
Posts: 14
Joined: Mon Nov 16, 2015 8:58 am

Multifrequency esfit errors

Post by AMullen »

Hi,

I've successfully performed fittings for multifrequency data before (using this topic: viewtopic.php?t=211). However, now I'm having problems and Matlab is throwing back errors when I try to start my fitting:
Error using +
Array dimensions must match for binary array op.

Error in resfields (line 715)

Error in pepper (line 608)

Error in pepper (line 127)

Error in multifreq (line 7)
freq1 = pepper(Sys,Exp,Opt);

Error in esfit>assess (line 808)

Error in esfit_simplex (line 77)

Error in esfit>runFitting (line 660)

Error while evaluating UIControl Callback
This all comes up after I've run my script, and the esfit window has popped up showing me the appended data sets. The problem isn't with my data, I don't think, since EasySpin reads and sticks together the two spectra in the window. I can't see where any of my workspace contents would have issues with array/matrix dimensions. Does anybody have any ideas as to what's actually wrong? Any insight or suggestions would be greatly appreciated. Please let me know if you want to see my script/function.
Stefan Stoll
EasySpin Creator
Posts: 1059
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Multifrequency esfit errors

Post by Stefan Stoll »

Please post your script.
AMullen
User
Posts: 14
Joined: Mon Nov 16, 2015 8:58 am

Re: Multifrequency esfit errors

Post by AMullen »

See below (I additionally use Morgan Bye's EPRtoolbox for cwzero):

Code: Select all

%Calls multifreq function to simulate and fit to 2 diff frequencies

clear;
clc;

%load in your epr data
[b1,y1,p1] = eprload('161209_HH_dW3_PAA_12K');  % X-band spectrum
[b2,y2,p2] = eprload('161221_HH_PAA_dW3_002');  % Q-band spectrum

% zero the baselines - ensure EPRtoolbox is downloaded and added to path
y3 = cwzero(y1);                               % zeroes X-band baseline
y4 = cwzero(y2);                               % zeroes Q-band baseline

% stick the two spectra together
y = [y3(:); y4(:)];

% set up your system - single set of parameters for both frequencies
Sys.Nucs = '1H';
Sys.g = [2.0031 2.0030 2.0019];
Sys.A = [8 2 8];
Sys.AStrain = [2 2 2];
Sys.lwpp = 0.6;

% provide some experimental parameters
% though some of these will be overwritten later
Exp.mwFreq = 9.390737;                          % X-band spectrum frequency
Exp.Range = [330 1215];                       % min field value at X-band, max field value at Q-band
Exp.nPoints = 2048;                             % add together no points for both spectra

% further define experimental parameters
Exp.f = [330 340 1205 1215];                % min & max field values at X-band, min & max field values at Q-band
Exp.n = [1024 1024];                            %  no points in both
Exp.mw = [9.390737 33.94365];                    % X-band spectrum frequency, Q-band spectrum frequency

% choose some parameters to  vary and by how much
Vary.g = [0.05 0.05 0.05];
Vary.A = [5 5 5];
Vary.AStrain = [0.5 0.5 0.5];
Vary.lwpp = 0.5;

esfit ('multifreq',y,Sys,Vary,Exp);             % calls multifreq function (ensure this has been added to path)
And the multifreq function:

Code: Select all

function y = multifreq(Sys,Exp,Opt)

%Frequency 1 = X-band
Exp.Range = [330 340];
Exp.nPoints = 1024; 
Exp.mwFreq = 9.390737;
freq1 = pepper(Sys,Exp,Opt);

%Frequency 2 = Q-band
Exp.Range = [1205 1215];
Exp.nPoints = 1024;
Exp.mwFreq = 33.94365;
freq2 = pepper(Sys,Exp,Opt);

y = [freq1(:); freq2(:)];

return

end
Stefan Stoll
EasySpin Creator
Posts: 1059
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Multifrequency esfit errors

Post by Stefan Stoll »

Please post the data as well. We cannot run this without them. Thanks
AMullen
User
Posts: 14
Joined: Mon Nov 16, 2015 8:58 am

Re: Multifrequency esfit errors

Post by AMullen »

Sorry!
Attachments
170112_EasySpinForum.zip
(9.08 KiB) Downloaded 289 times
Stefan Stoll
EasySpin Creator
Posts: 1059
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Multifrequency esfit errors

Post by Stefan Stoll »

I cannot reproduce this problem. With ES 5.1.8 and Matlab R2016b, this runs without problems. The esfit GUI displays, and after pressing Start, the fitting runs for many iterations without errors.
AMullen
User
Posts: 14
Joined: Mon Nov 16, 2015 8:58 am

Re: Multifrequency esfit errors

Post by AMullen »

I have just tried on another computer as well, and it runs fine. It must be a problem with my computer/versions. I apologise for the inconvenience! I will try using a different ES version to see if it persists. Thank you for your time anyway.
thanasis
Local Expert
Posts: 242
Joined: Thu Jan 21, 2016 6:28 am
Location: Strasbourg

Re: Multifrequency esfit errors

Post by thanasis »

Nice implementation!

Just a minor point: apparently the cwzero function only works on column arrays. The eprload function when used on spc data yields a row, i.e. a 1xn array. To treat a spectrum you load from an spc file, you need to give:

Code: Select all

y3 = cwzero(y1.');
otherwise you get an error.

When importing DTA files, eprload yields a column array, so no problem there.
AMullen
User
Posts: 14
Joined: Mon Nov 16, 2015 8:58 am

Re: Multifrequency esfit errors

Post by AMullen »

All of the spectrometers I use export in DTA format, so I've had no issues with that, but that's certainly useful to know, thanks!

I've managed to resolve my error problems. At first I tried updating to the newest version of EasySpin (from 5.1.5 to 5.1.9 this morning) to no avail, but it seems moving to MATLAB R2016b (from R2015a) has fixed it. I don't know if there was a compatibility issue or something with that version on MATLAB, but I just thought I'd post this in case someone comes across a similar problem for whatever reason.
Post Reply