Filter löschen
Filter löschen

finding values and ignoring repeats

3 Ansichten (letzte 30 Tage)
Bernard
Bernard am 26 Aug. 2013
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.

Akzeptierte Antwort

Roger Stafford
Roger Stafford am 26 Aug. 2013
[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'.

Weitere Antworten (1)

the cyclist
the cyclist am 26 Aug. 2013
I did not follow your text, but maybe the unique() command helps you?

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by