having failed to post the first question in a clear way, I will try to be more specific.
I have two 2d matrices, one with 5 columns (let's call it data) and the other with 7 (let's call it BMU). Let's call the 5 column submatrix photometry and the last two columns respectively z and z_err.
What I would like to do is, excluded the last two columns of BMU, calculate all the euclidean distances between the data objects and the BMU objects, then for each data objects find the closest k BMU objects. (here I rearrange the distance matrix and so I can't associate a distance to a specific BMU object)
Done so, I would like to retrieve this closest k objects in the BMU matrix and use the 6th and 7th column to perform some operation.
In order to store and retrieve all these informations that I need, I was trying to create some sort of dictionary. So, when I calculate the distances, I can use an ID to associate the particular distance to the features of the BMu object (photometry, z and z_err) even if I have to rearrange them.
thanks for any help :)