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

조회 수: 4 (최근 30일)
PsykotropyK
PsykotropyK 2020년 2월 12일
답변: Sindar 2020년 2월 12일
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.

답변 (1개)

Sindar
Sindar 2020년 2월 12일
It sounds like
weights = v(m);
should work

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by