Borrar filtros
Borrar filtros

finding values and ignoring repeats

3 visualizaciones (últimos 30 días)
Bernard
Bernard el 26 de Ag. de 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.

Respuesta aceptada

Roger Stafford
Roger Stafford el 26 de Ag. de 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'.

Más respuestas (1)

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

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by