How can I sort cell arrays along with vectors?

1 回表示 (過去 30 日間)
dormant
dormant 2024 年 1 月 4 日
コメント済み: dormant 2024 年 1 月 5 日
I am getting very confused by all the documentation on sorting in MATLAB, so can someone please answer this very specific question?
I have a number of numeric vectors along with two associated cell arrays, ie
How can I sort them all together with the order defined by one of the numeric vectors?
  3 件のコメント
Stephen23
Stephen23 2024 年 1 月 4 日
編集済み: Stephen23 2024 年 1 月 5 日
"How can I sort them all together with the order defined by one of the numeric vectors?"
With difficulty: having lots of separate variables makes this task much harder.
If you stored the data in one table then it would be very easy.
dormant
dormant 2024 年 1 月 5 日
I tried using a table before, but had problems because some of the values in the numeric vectors were undefined or NaNs. I can't remember the details, but I'll look into it again.

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

採用された回答

Walter Roberson
Walter Roberson 2024 年 1 月 4 日
[~, SortOrder] = sort(vtstring_datim_begs); %or as appropriate
s_ends = vtstring_datim_ends(SortOrder);
s_durs = vtstring_durs(SortOrder);
s_ids = vtstring_ids(SortOrder);
s_max_MLs = vtstring_max_MLs(SortOrder);
%and so on
  1 件のコメント
dormant
dormant 2024 年 1 月 5 日
Many thanks.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by