A and B are coupled vectors. How can I get from A->A_new B-> B_new?

2 ビュー (過去 30 日間)
Amelos
Amelos 2016 年 11 月 17 日
コメント済み: Amelos 2016 年 11 月 18 日
A = [0 1 2 3 4 8 3 4 5];
B = [0.1 0.2 0.2 0.3 0.4 0.2 0.3 0.5 0.5];
A_new = [0 1 2 3 4 8 5];
B_new = [0.1 0.2 0.2 0.6 0.9 0.2 0.5];

採用された回答

Guillaume
Guillaume 2016 年 11 月 17 日
[A_new, ~, columns] = unique(A, 'stable') %stable optional if ordering does not matter
B_new = accumarray(columns, B).'

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAudio I/O and Waveform Generation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by