How to add values in a vector based on repeating values on another?

1 回表示 (過去 30 日間)
Maaz Madha
Maaz Madha 2021 年 2 月 25 日
回答済み: Walter Roberson 2021 年 2 月 26 日
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).

採用された回答

Walter Roberson
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 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by