Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 为什么对于点云数据的最近邻,我的代码和标准代码给出的结果不一样_Matlab_Nearest Neighbor_Point Clouds - Fatal编程技术网

Matlab 为什么对于点云数据的最近邻,我的代码和标准代码给出的结果不一样

Matlab 为什么对于点云数据的最近邻,我的代码和标准代码给出的结果不一样,matlab,nearest-neighbor,point-clouds,Matlab,Nearest Neighbor,Point Clouds,嗨,我是Matlab新手,正在尝试使用点云。我从云中随机选取了一个点,并编写了一个代码来找出它的10个最近邻居。然而,当我使用标准的Matlab函数时,它给出的结果却不一样……有人能解释为什么。。我的代码是: ptCloud = pcread('Point Cloud\bunny\reconstruction\bun_zipper.ply'); xyz = ptCloud.Location; N=size(xyz,1); r=ceil((N/(100*rand))+10*rand); point

嗨,我是Matlab新手,正在尝试使用点云。我从云中随机选取了一个点,并编写了一个代码来找出它的10个最近邻居。然而,当我使用标准的Matlab函数时,它给出的结果却不一样……有人能解释为什么。。我的代码是:

ptCloud = pcread('Point Cloud\bunny\reconstruction\bun_zipper.ply');
xyz = ptCloud.Location;
N=size(xyz,1);
r=ceil((N/(100*rand))+10*rand);
point=x(r,:,:);

dist=sqrt(sum((xyz-repmat(point,N,1)).^2,2));

[d,ind]=sort(dist,'descend');

ind_closest = ind(1:10);

pt_closest = xyz(ind_closest,:,:);
输出:

[27955;14360;24204;13755;25659;14345;28071;24801;30746;25946]
1073    18275   18274   19122   18276   21598   20725   20724   1074    18273
使用标准功能时:

[ind1,d1]=**knnsearch**(xyz,point,'k',10);
输出:

[27955;14360;24204;13755;25659;14345;28071;24801;30746;25946]
1073    18275   18274   19122   18276   21598   20725   20724   1074    18273

请告诉我哪里做错了?

您正在按降序排列距离。这意味着最大距离首先出现在排序结果中。尝试将顺序更改为“升序”。非常感谢……)我真蠢:)