Matrix problems?

1 次查看(过去 30 天)
Ami
Ami 2011-6-6
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.

回答(2 个)

Walter Roberson
Walter Roberson 2011-6-6
Use the two-output version of sort to get the indices that the values originally came from.

Chetan
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');

类别

Help CenterFile Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by