Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Comparing two matrix elements summing third and storing them separately

1 visualización (últimos 30 días)
N/A
N/A el 7 de Jul. de 2019
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
whenever the elemnts in column 1 and 3 both are repeated elsewhere in matrix then only third column should get added up
e.g
A=
18 18 1
17 20 2
18 18 1
17 25 2
19 17 3
18 18 1
19 17 3
then answer should be
18 18 1
17 20 2
18 18 2
17 25 2
19 17 3
18 18 3
19 17 6
After that i want that the final matriz should be of the form
x = [ 17 20 2
17 25 2
18 18 3
19 17 6]

Respuestas (2)

madhan ravi
madhan ravi el 7 de Jul. de 2019
T = array2table(A);
t = groupsummary(T,{'A1','A2'},'sum');
x = t{:,[1,2,end]}

Andrei Bobrov
Andrei Bobrov el 7 de Jul. de 2019
[B,BB] = groupsummary(A(:,3),A(:,1:2),'sum');
out = [BB{:},B];

La pregunta está cerrada.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by