sorting rows

조회 수: 8 (최근 30일)
kash
kash 2012년 5월 15일
I have a matrix ,i have to sort them by "time" variable plz tell how to proceed
  댓글 수: 1
Andrei Bobrov
Andrei Bobrov 2012년 5월 15일
example your data

댓글을 달려면 로그인하십시오.

채택된 답변

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일
  댓글 수: 1
kash
kash 2012년 5월 15일
Andreas i means sorting by "time" variable
rows sorting by "time" variable

댓글을 달려면 로그인하십시오.

카테고리

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