change the order of array

3 ビュー (過去 30 日間)
NA
NA 2018 年 10 月 22 日
コメント済み: Bruno Luong 2018 年 10 月 22 日
I have M=[1,2 ;1,5; 2,4;2,5;4,5; 4,9;5,6;6,11;9,10;10,11] I want to change the order of numbers I want this answer N=[1,2;1,4;2,3;2,4;3,4;3,6;4,5;5,8;6,7;7,8]
  1 件のコメント
madhan ravi
madhan ravi 2018 年 10 月 22 日
explain the pattern

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

採用された回答

Bruno Luong
Bruno Luong 2018 年 10 月 22 日
[~,N] = ismember(M,unique(M(:)))
  2 件のコメント
NA
NA 2018 年 10 月 22 日
is there any possibilities to save this order? for example 5 changes to 4, 8 changes to 11.
Bruno Luong
Bruno Luong 2018 年 10 月 22 日
I guess you mean 11 changes to 8 (not the opposite).
u = unique(M(:));
map = [u,(1:length(u)).']

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by