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

3 Ansichten (letzte 30 Tage)
Amelos
Amelos am 17 Nov. 2016
Kommentiert: Amelos am 18 Nov. 2016
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];

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Audio I/O and Waveform Generation finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by