How to get sum of all the order values for a given id of a column in matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Mitul saraiya
am 19 Dez. 2014
Kommentiert: Mitul saraiya
am 20 Dez. 2014
i have 2 columns and 10 rows
1 10
2 29
2 34
2 79
3 11
3 20
3 11
4 9
4 1
5 10
i want the add numbers having same value in first column The answer i want is using loop or any other operation
1 10
2 142
3 42
4 10
5 10
0 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 19 Dez. 2014
Bearbeitet: Azzi Abdelmalek
am 19 Dez. 2014
A=[1 10;2 29;2 34;2 79;3 11;3 20;3 11;4 9;4 1;5 10]
out=[unique(A(:,1)) accumarray(A(:,1),A(:,2))]
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!