这是什么错误?
指数超出矩阵尺寸 评估错误(第5行)
binTempX(I,[1,2,3,4,5,6,7,8])= parentXY(I,[1,2,3,4,5,6,7,8]);
function [tempX_Y_FXY] = evalution(parentXY,fXY)
for i=1:6
binTempX(i,[1,2,3,4,5,6,7,8])=parentXY(i,[1,2,3,4,5,6,7,8]);
binTempY(i,[9,10,11,12,13,14,15,16],8)=parentXY(i,[9,10,11,12,13,14,15,16]);
decTempX=bin2dec(binTempX(i,[1,2,3,4,5,6,7,8]));
decTempY=bin2dec(binTempY(i,[9,10,11,12,13,14,15,16]));
tempX_Y_FXY(i,1)=decTempX;
tempX_Y_FXY(i,2)=decTempY;
tempX_Y_FXY(i,3)=fXY(decTempX,decTempY);
end
tempX_Y_FXY=sortrows(tempX_Y_FXY,3);
end
答案 0 :(得分:0)
binTempX(i,[1,2,3,4,5,6,7,8])=parentXY(i,[1,2,3,4,5,6,7,8]);
%%% ------- what is this 8 doing here???
binTempY(i,[9,10,11,12,13,14,15,16],**8**)=parentXY(i,[9,10,11,12,13,14,15,16]);
decTempX=bin2dec(binTempX(i,[1,2,3,4,5,6,7,8]));
decTempY=bin2dec(binTempY(i,[9,10,11,12,13,14,15,16]));
tempX_Y_FXY(i,1)=decTempX;
tempX_Y_FXY(i,2)=decTempY;
tempX_Y_FXY(i,3)=fXY(decTempX,decTempY);
将其更改为:
binTempX(i,1:8)=parentXY(i,1:8);
% removed the 8, because I think it is typo??
binTempY(i,9:16)=parentXY(i,9:16);
decTempX=bin2dec(binTempX(i,1:8));
decTempY=bin2dec(binTempY(i,9:16));
tempX_Y_FXY(i,1)=decTempX;
tempX_Y_FXY(i,2)=decTempY;
tempX_Y_FXY(i,3)=fXY(decTempX,decTempY);
如果要选择/分配多个连续列,请使用1:8表示法。两者都应该有效,但在我看来,第二个更清晰,更容易维护。
就像烧杯说的那样,检查矩阵的大小,你使用的矩阵至少有6行16列吗?