Vector Comparison According to Entities

1 回表示 (過去 30 日間)
Alper Topuz
Alper Topuz 2019 年 6 月 14 日
編集済み: Matt J 2019 年 6 月 15 日
I have the following vector A.
A = [21, 20,2,19, 3, 18, 4,17, 5,16, 6,15, 7,14, 8, 13, 9, 10;...
2, 3 ,21, 4, 20, 5,19, 6,18, 7,17, 8,16, 9,15,10,14,13]
I would like to obtain a 1xN numbering vector where N is the number of columns of A which assigns the same number to columns that are flipped version of each other. (i.e column1 and column3. column1 = [21;2] column3 = [2,21] column1 = flip(column2)). Thus the numbering must be like this
n = [ 1 2 1 3 2 4 3 5 6 7 5 6 7 8 6 9 8 9];

採用された回答

Matt J
Matt J 2019 年 6 月 15 日
編集済み: Matt J 2019 年 6 月 15 日
[~,~,n]=unique(sort(A,1).','rows');
n=n(:).';

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by