Error using matlab.gra​phics.axis​.Axes/set

조회 수: 7 (최근 30일)
MS
MS 2022년 12월 15일
댓글: Voss 2022년 12월 15일
Do not know the remedy for the below mentioned error.
Error using matlab.graphics.axis.Axes/set
Value must be a 1x2 vector of numeric type in which the second element is greater than the first element or is Inf.
Error in axis>LocSetLimits (line 289)
set(ax,...
Error in axis (line 114)
LocSetLimits(ax(j),cur_arg,names);
Error in peakfit (line 1610)
axis([min(xx) max(xx) 0 uyy]);
%% Inputs
i=0;
for fna= 2506 %2506:2520
fname=sprintf('HB2B_%d.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
%%%%% Error in the bottom line %%%%%
[results,resultserr]=peakfit(signal,center,window,NumPeaks,peakshape,extra, NumTrials, start, BaselineMode,fixedparameters,plots);
%%%%%% Error%%%%%%%%%%%%%%
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

채택된 답변

Voss
Voss 2022년 12월 15일
편집: Voss 2022년 12월 15일
First, thank you for including data and runnable code.
Second, it appears to run fine here (see below).
Try updating your peakfit.m by downloading the latest version (it's attached to this answer too):
I just downloaded that, and I notice its line 1610 is not the same as the line 1610 reported in your error message, so probably getting the latest version will fix the problem.
unzip('HB2B_2506.zip')
%% Inputs
i=0;
for fna= 2506 %2506:2520
fname=sprintf('HB2B_%d.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
%%%%% Error in the bottom line %%%%%
[results,resultserr]=peakfit(signal,center,window,NumPeaks,peakshape,extra, NumTrials, start, BaselineMode,fixedparameters,plots);
%%%%%% Error%%%%%%%%%%%%%%
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
X-axis flipped.
  댓글 수: 2
MS
MS 2022년 12월 15일
Thank you. The code ran with new version.
Voss
Voss 2022년 12월 15일
You're welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by