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

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 5월 15일

0 개 추천

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일

0 개 추천

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에 대해 자세히 알아보기

태그

질문:

2012년 5월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by