Debugging 元件间距离
我在计算y方向(而不是x方向)上像素之间的距离时犯了一个愚蠢的错误。这应该更清楚:Debugging 元件间距离,debugging,matlab,Debugging,Matlab,我在计算y方向(而不是x方向)上像素之间的距离时犯了一个愚蠢的错误。这应该更清楚: % Distance matrix for pxRow = 1:h % fixed pixel row for pxCol = 1:w % fixed pixel column for r = 1:h % row of distant pixel for c = 1:w % column of distant pixel Rx(c,r) = sqrt((r-pxR
% Distance matrix
for pxRow = 1:h % fixed pixel row
for pxCol = 1:w % fixed pixel column
for r = 1:h % row of distant pixel
for c = 1:w % column of distant pixel
Rx(c,r) = sqrt((r-pxRow)^2); % get distance to each pixel x direction
Ry(c,r) = sqrt((c-pxCol)^2); % get distance to each pixel y direction
end
end
Rix(i) = {Rnx};
Riy(i) = {Rny};
i = i+1;
end
end
Rix = reshape(Rix, w, h);
Riy = reshape(Riy, w, h);
在哪里
Rix =
NaN 1.000 0.500 0.333
NaN 1.000 0.500 0.333
NaN 1.000 0.500 0.333
这是正确的,但是
Riy =
NaN NaN NaN NaN
1.000 1.000 1.000 1.000
1.000 1.000 1.000 1.000
这是不正确的,因为我希望Riy只是一个旋转的Rix
这里的错误在哪里
提前感谢。很难看出你真正想要实现的目标。考虑添加一个你想要做的解释性图像或者详细地说明那些是<代码> RX,<代码> Ry/<代码>,<代码> RNX和<代码> RNY < /代码>我不认为你正确地粘贴了你的代码。代码>Rnx和
Rny
未在for循环中的任何位置设置。你是说Rx
和Ry
,还是你漏掉了几行?@sfstewman^^^^是的,你说得对!应该是Rx Ry(我一定是在调试过程中)。这个问题现在已经解决了。