How to sort values and strings

조회 수: 2 (최근 30일)
Leon
Leon 2013년 11월 6일
댓글: Leon 2013년 11월 6일
I have a data set with several variables, their sizes are all (10000, 1), i.e., 10000 rows and 1 column.
Stations are strings, but depths and other variables are numerical values. I want to sort all of them according to depth. How should I achieve this?
Thank you

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 6일
편집: Azzi Abdelmalek 2013년 11월 6일
Stations={'a';'b';'c'}
depth=[1;3;2]
height=[3;1;2]
v=[Stations num2cell([depth height])]
sortrows(v,2) % depth is in the second column
  댓글 수: 1
Leon
Leon 2013년 11월 6일
Thank you so much, Azzi! It works.

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

추가 답변 (0개)

카테고리

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