如果条件为真,我想减少索引。但是当我执行i = i-1
时,它就开始循环。下面有一个例子。
for i = 1:sizex
for j = 2:unix
if temp == uniorderxy(j,1)
manDist = abs((uniorderxy(j,2)-xy(i,1)))+abs((uniorderxy(j,3)-xy(i,2)));
if manDist <= temDist
temDist = manDist;
temX = uniorderxy(j,2);
temY = uniorderxy(j,3);
end
if j == unix
temX = uniorderxy(j,2);
temY = uniorderxy(j,3);
temxy = [temX temY];
xy = [xy; temxy];
end
else
temp = uniorderxy(j,1);
temxy = [temX temY];
xy = [xy; temxy];
i = i+1;
j = j-1;
[sizex, y] = size(xy);
temDist = 100;
end
end
end
在其他部分,应减小 j值。例如,当j=5
时应将其递减为4,以便在for循环再次启动时应以5继续。但是在我的代码中,它将继续以6继续。