Sort Cell Structure according to specific row

Hi! I've been trying to sort my Cell, so that the columms are displayed in a crescent order of the first row elements. Unfortunately the "sortrows" function applied with the transposed cell didn't seem to work (maybe because my second row is composed by arrays). Could anyone suggest another way?
Excerpt of the cell below:
Goal ist to have the following:
{0 8 21 32 52 62, [ ] [ ] [ ] [ ] [ ] [ ]}
Thx a Lot!

2 件のコメント

Adam Danz
Adam Danz 2020 年 10 月 23 日
So, you've got 1 cell of size 2X6 where the first row is a 1x6 vector and the 2nd row is a 4xn matrix of doubles. You want to change the order of the first row only, or do you want to change the order of the 2nd row, too, according to the new order of the 1st row?
Leonel Mendes
Leonel Mendes 2020 年 10 月 23 日
I want to change the order of all the rows. Sry, wasn't that clear.

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

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 10 月 23 日

0 投票

Are you tying to do something like this
C; % 2xn cell array
[~, idx] = sort([C{1,:}]);
C = C(:, idx);

1 件のコメント

Leonel Mendes
Leonel Mendes 2020 年 10 月 23 日
Thx!! Exactly, I was using the wrong Syntax! =D

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および 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