フィルターのクリア

finding values and ignoring repeats

4 ビュー (過去 30 日間)
Bernard
Bernard 2013 年 8 月 26 日
I have a a series of points that end up making up nodes of a tree. this is in a Nx3 matrix of x y z coordinates, I have another list of xyz coordinates of some random points say Mx3, M<<N. I did a NNS to find the closest nodes and have a vector called distvec that is the distance between a point in M and all points in N, from that I go to find(distvec==min(min(distvec))) which would give me the index of the min value in distvec. The only problem is sometimes there are duplicate points in N that end up being the min distance to a point in M so when I do the search it can't find index and I get error. I know this coding of using find is fickle and does anyone know how to ignore the duplicates and just pick the first.

採用された回答

Roger Stafford
Roger Stafford 2013 年 8 月 26 日
[t,ir] = min(distvec);
[m,ic] = min(t);
I = [ir(ic),ic];
I has the indices of the minimum value in 'distvec' and 'm' is that minimum value. You don't need to use 'find'.
  1 件のコメント
Bernard
Bernard 2013 年 8 月 26 日
yeah I discovered this thanks!

サインインしてコメントする。

その他の回答 (1 件)

the cyclist
the cyclist 2013 年 8 月 26 日
I did not follow your text, but maybe the unique() command helps you?

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by