How to sort values and strings

3 ビュー (過去 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 Center および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by