Sort matrix by rows

2 ビュー (過去 30 日間)
Kasper
Kasper 2014 年 5 月 6 日
コメント済み: Kasper 2014 年 5 月 6 日
I have a matrix in 3x20 cell array.
I now have to first sort my matrix by row 2 in ascending order and after that sort by row 2 and 3.
I've tried
D = sortrows(QRT,3)
but get the error message:
Error using char
Cell elements must be character arrays.
Error in sortrows>sort_cell_back_to_front (line 136)
tmp = char(x(ndx,k));
Error in sortrows (line 88)
ndx = sort_cell_back_to_front(x_sub, col);
My first row is characters and the rest is numbers.
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 5 月 6 日
post a sample of your data
Kasper
Kasper 2014 年 5 月 6 日
I figured it out. Just had to write it like this:
D = sortrows(QRT',3)
I had mixed up columns and rows xD - My data was in 3 columns, instead of 3 rows. So that's why I couldn't sort it. The little ' did the work.

サインインしてコメントする。

回答 (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