0

我有两个带有坐标的矩阵((intx(i),inty(i),intz(i))和Ceres(j)),我需要找到彼此最接近的两个点。从 MATLAB 代码中,我希望得到第一个矩阵中的点之间的距离,即最接近第二个矩阵 Ceres 上的点。

但是,我没有在 disttemp 中将这个最小值作为单个数字获取,而是得到了一个长度数组(ceres_lim)。

我究竟做错了什么?

disttemp = 100000; % large number greater that the expected min distance

for i = 1:length(intz) % size of interpolated line point vector

    for j = ceres_lim % array of indices close to line 

        distcur = pdist2([intx(i),inty(i),intz(i)],[Ceres(j,1),Ceres(j,2),Ceres(j,3)],'euclidean'); % distance between point on interpolated line (i) and scatter point on Ceres (j)

        if distcur < disttemp 
            disttemp = distcur; % statement saves smallest value of distcur to disttemp to find min distance
        end
    end
end
4

0 回答 0