Array of index, should return indexed values on the same array format

4 visualizaciones (últimos 30 días)
PsykotropyK
PsykotropyK el 12 de Feb. de 2020
Respondida: Sindar el 12 de Feb. de 2020
Hello,
I used knnsearch to find the 100 nearest points from a set of points. I end up having a matrix m=Nx100 that lists all the indexes of the 100 closest to a point. For instance I have (matrix shortened to 4x6):
m=[1 215 106405 210 37814 21780 ; 2 197 13769 21537 40151 40168 ; 3 200 212 503 3375 3943 ; 4 241 250 262 266 271]
Here it means that
The 1st point's 6 closest points are indexes 1, 215, 106405, 210, 37814, 21780
The 2nd point's 6 closest points are indexes 2, 197, 13769, 21537, 40151, 40168
I then have a vector v which represents a weight associated to each points. Hence I would like to have a matrix, Nx100, where each value would be the v(i), something like :
[v(1) v(215) v(106405) v(210) v(37814) v(21780) ; v(2) v(197) v(13769)....................]
I am sure there is a simple way to do it, but I couldn't find the answer.

Respuestas (1)

Sindar
Sindar el 12 de Feb. de 2020
It sounds like
weights = v(m);
should work

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by