|
Hi
I have a distance matrix of numeric values, and data labels on an array of cells. I want to sort the distance matrix on both dimensions, so that the smallest values are all on the left top corner of the distance matrix, and the highest values are all on the right bottom corner. I still need to use the indices return to find the sorted permutation of the labels. I was thinking that the following code should do it:
upTriangle = triu(distMatrix);
[DistMatSorted,IX] = sort(upTriangle, 2);
for j=1:m
for i=1:n
DistMatSorted(i,j) = DistMatSorted(j,i);
end
DistMatLabelsSorted(j) = DistMatLabels(IX(1, j));
end
but I didn't receive the right sorting, but I received the right permutations of indices with the new sorting. The sorting that I am looking for is achieved using dim = 1 in the sorting function input:
[DistMatSorted,IX] = sort(upTriangle, 1);
However, the labels perumtations are messed up, with repeatitions and of course missing labels.
I do not know how to correlate the sort help function to the data organization that I have (i.e. having the labels in a one dimensional array while sorting a matrix, the help is focused on finding the permutations of the matrix itself, and not a related vector),
Am I making myself clear? I really need help in this function, lots of problems are based on the wrong sorting of the labels with the distance matrix,
thank you very much in advance,
Kind Regads,
Manal
|