How to add values in a vector based on repeating values on another?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Maaz Madha
le 25 Fév 2021
Réponse apportée : Walter Roberson
le 26 Fév 2021
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 commentaires
Réponse acceptée
Walter Roberson
le 26 Fév 2021
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!