Index exceeds the number of array elements.
조회 수: 2 (최근 30일)
이전 댓글 표시
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)
댓글 수: 0
채택된 답변
Walter Roberson
2022년 12월 16일
이동: Walter Roberson
2022년 12월 16일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!