How to add values in a vector based on repeating values on another?
2 次查看(过去 30 天)
显示 更早的评论
Hi
I have two vectors of the same length and . I want it to be so that everytime a value in the first array repeats(for example the 2 in 1 and 9) the values in the second array would add up(so 7.8953..+8.5184).
0 个评论
采纳的回答
Walter Roberson
2021-2-26
accumarray(first_vector, second_vector)
This requires that first_vector is positive integers. The size of the result will be max(first_vector) x 1
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!