Matrix problems?
1 次查看(过去 30 天)
显示 更早的评论
I have a 5x5 matriz and a vector of 5 numbers, I need to sort it, like the number one take one numer of the 1rst row of the matrix, I can do that and it send me this matrix
time=[1,7597 1,634 1,7157 1,6738 5 2,3452 2,1777 2,2866 4 2,6901 3,1412 2,9169 3 2,988 3,6032 1 2,69220 2,8268 2,7579 3,3256 4,5961 2 4,4812 4,3719 5,2720]
What I want is to know is the number that is was before in that position, cause I have to do do a sum of the 5 positions.
0 个评论
回答(2 个)
Walter Roberson
2011-6-6
Use the two-output version of sort to get the indices that the values originally came from.
0 个评论
Chetan
2011-6-6
>>>What I want is to know is the number that is was before in that position, cause I have to do do a sum of the 5 positions.
> 'Indices' will give you the previous location of the sorted values
[valuesAftersorting indices]=sort(Put variable you want to sort here, 'ascend/descend');
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!