sorting rows

I have a matrix ,i have to sort them by "time" variable plz tell how to proceed

 采纳的回答

Andrei Bobrov
Andrei Bobrov 2012-5-15
time1 = rand(8,1);
yourmatrix = randi(30,8);
solution:
[id,id] = sort(time1);
out = yourmatrix(id,:)
OR:
out1 = sortrows([time1(:), yourmatrix],1);
out = out1(:,2:end)

更多回答(1 个)

Andreas Goser
Andreas Goser 2012-5-15
doc sortrows

1 个评论

kash
kash 2012-5-15
Andreas i means sorting by "time" variable
rows sorting by "time" variable

请先登录,再进行评论。

类别

在 帮助中心 和 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!

Translated by