Sort a matrix according to the index of a vector
조회 수: 3 (최근 30일)
이전 댓글 표시
I have following labels for the rows and columns of a square matrix:
labels = {'dog', 'car', 'fish'}'
The corresponding matrix that expresses the semantic similarity between the terms is
D = [[0 0.8 0.2];
[0.8 0 0.7];
[0.2 0.7 0]];
I want to sort matrix and labels after following index
idx = [1 2 1];
Sorting the labels is easy:
[values,isort]=sort(idx);
labels_sort = labels(isort)
labels_sort =
3×1 cell array
{'dog' }
{'fish'}
{'car' }
But how can i sort the matrix D accordingly?
댓글 수: 2
KL
2017년 11월 20일
편집: KL
2017년 11월 20일
You have created the very same question 3 times. You haven't replied to the comments on your previous posts but just deleted them entirely. Please do not spam the forum, if the answer below is not what you are looking for, provide more information (such as the expected result) and ask follow-up questions.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!