sorting rows

8 views (last 30 days)
kash
kash on 15 May 2012
I have a matrix ,i have to sort them by "time" variable plz tell how to proceed
  1 Comment
Andrei Bobrov
Andrei Bobrov on 15 May 2012
example your data

Sign in to comment.

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 15 May 2012
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)

More Answers (1)

Andreas Goser
Andreas Goser on 15 May 2012
doc sortrows
  1 Comment
kash
kash on 15 May 2012
Andreas i means sorting by "time" variable
rows sorting by "time" variable

Sign in to comment.

Categories

Find more on Shifting and Sorting Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!