A and B are coupled vectors. How can I get from A->A_new B-> B_new?
2 次查看(过去 30 天)
显示 更早的评论
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];
0 个评论
采纳的回答
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 Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!