How to sum every elements that have the same frequency?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
mrbond99
el 20 de Ag. de 2020
Comentada: mrbond99
el 20 de Ag. de 2020
Suppose I have 2 vectors of the same length.
A = [0.2 0.4 0.8 0.6 1.2 0.3];
B = [ 2 2 1 2 1 1];
The result that I want ---> A+B = [(0.2+0.4+0.6),(0.8+1.2+0.3)].
Please help. Thanks in advance.
0 comentarios
Respuesta aceptada
KSSV
el 20 de Ag. de 2020
A = [0.2 0.4 0.8 0.6 1.2 0.3];
B = [ 2 2 1 2 1 1];
iwant = [sum(A(B==2)), sum(A(B==1))]
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!