Index exceeds the number of array elements.

2 views (last 30 days)
Please let me know a solution for the error. Data attached here.
Index exceeds the number of array elements. Index must not exceed 1.
Error in analyzeHFIRdatad0 (line 36)
theta2 = h5read(fname,sprintf('%s/2theta',info.Groups(5).Name));
i=0;
for fna= 2506:2507
fname=sprintf('HB2B_%d.nxs.h5',fna);
i=i+1;
NumPeaks=1;
NumTrials=15;%the higher the number, the better the fit is (but slower), typical value: 10
BaselineMode=1;%0 no baseline, 1 linear, 2 quadratic, 3 flat(not working yet)
peakshape=33;%Ps. Voigt
window=8e-12;% center +/- (window/2) corresponds to the fitting window
center=1.09e-10;
fwhm=1; start=[center fwhm];%first guess (ignore=0)
fixedparameters=[peakshape start(1) start(2)];%specifies fixed peakshape, pos, width (ignore=0)
plots=1;%plot for each peakfit
extra=1;%all peaks with same shape: use extra=1
%% Code starts
info = h5info(fname);
theta2 = h5read(fname,sprintf('%s/2theta',info.Groups(5).Name));
counts = h5read(fname,sprintf('%s/main',info.Groups(5).Name));
wave=h5read(fname,'/instrument/monochromator setting/wave length')*1e-10;
d=wave./(2.*sin(theta2./2*pi/180));
signal=[d,counts];%d-spacing
[results,resultserr]=peakfit(signal,center,window,NumPeaks,peakshape,extra, NumTrials, start, BaselineMode,fixedparameters,plots);
pos(i)=results(1,2); int(i)=results(1,3);
w(i)=results(1,4); area(i)=results(1,5);
err(i)=resultserr(1); r2(i)=resultserr(2);
end
d0=mean(pos)
dlmwrite('d0.csv',d0,'precision',10)

Accepted Answer

Walter Roberson
Walter Roberson on 16 Dec 2022
Moved: Walter Roberson on 16 Dec 2022
I can find 2theta as /entry/DASlogs/2theta but there is no main anywhere in the dataset.
I can find /entry/instrument but there is no monochromator setting anywhere in the dataset.

More Answers (0)

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!