我的代码有效,但每次运行到第 13 行时,它都会在命令窗口中写入:“警告:冒号运算符在用作索引时需要整数操作数”。我的代码的相关部分如下所示:
filename = uigetfile;
obj = mmreader(filename);
nFrames=obj.NumberOfFrames;
for k = 1 : nFrames
this_frame = read(obj, k);
thisfig = figure();
thisax = axes('Parent', thisfig);
image(this_frame, 'Parent', thisax);
if k==1
handle=imrect;
pos=handle.getPosition;
end
partOf=this_frame(pos(2):pos(2)+pos(4),pos(1):pos(1)+pos(3));%this is line 13
vector(k)=mean2(partOf);
title(thisax, sprintf('Frame #%d', k));
end
为什么会出现此警告,我可以忽略它吗?