finding values and ignoring repeats
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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.
0 Commenti
Risposta accettata
Roger Stafford
il 26 Ago 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'.
Più risposte (1)
the cyclist
il 26 Ago 2013
I did not follow your text, but maybe the unique() command helps you?
0 Commenti
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!