How to make comparison between paired elements?
    5 ビュー (過去 30 日間)
  
       古いコメントを表示
    
Hi, I would like to compare pair of adjacent elements of array. For example:
if 
  A=[1;
     2;
     1;
     3;
     2;
     4]
In this case the pairs are (1 2) (1 3) (2 4)... So in this case I have "unique" pairs.
But for example:
    A=[1;
       2;
       1;
       2;
       2;
       4]
In this case the pairs are (1 2) (1 2) (2 4) .... In this case I don't have "unique" pairs.
How can I make the comparisson of pairs, considering the pair is form with the adjacent element.
thanks
0 件のコメント
採用された回答
  Star Strider
      
      
 2014 年 6 月 19 日
        A=[1;
       2;
       1;
       2;
       2;
       4]
Ar = reshape(A, 2, [])';
UA = unique(Ar,'rows')
The ‘UA’ matrix rows are the unique adjacent elements of your ‘A’ vector.
4 件のコメント
その他の回答 (0 件)
参考
カテゴリ
				Help Center および File Exchange で Matrices and Arrays についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


