我有两个带有坐标的矩阵((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