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

6 次查看(过去 30 天)
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by