フィルターのクリア

Numbering the rows of a matrix giving the same number to equal rows?

2 ビュー (過去 30 日間)
MRC
MRC 2014 年 5 月 7 日
回答済み: the cyclist 2014 年 5 月 7 日
Hi all, I have a matrix A mxn with some equivalent rows; the equivalent rows can only be adjacent. I want to create without looping a vector C mx1 in which I number from 1 to b<m the rows of A giving the same number to the same rows. E.g.
A=[1 2 3 4; 5 6 7 8; 5 6 7 8; 5 6 7 8; 0 0 0 0; 8 9 0 1; 8 9 0 1]
C=[1 2 2 2 3 4 4];
Could you help me?

採用された回答

the cyclist
the cyclist 2014 年 5 月 7 日
[~,~,C] = unique(A,'rows','stable')

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by