Borrar filtros
Borrar filtros

Grouping the data of two variables by sum

2 visualizaciones (últimos 30 días)
Chinmai Sai
Chinmai Sai el 11 de Nov. de 2023
Respondida: the cyclist el 11 de Nov. de 2023
I have a data with 3 columns R, Z, E. E is a function of R and Z. I would like to add the E coulmn for the same value of R and Z. For example, from the data below, I want to add all the E values for R=1 and Z= 3. Can I get some suggestion?
R Z E
1 3 0.5
3 2 0.4
4 1 0.3
1 3 0.1
1 2 0.5
3 2 0.4
  3 comentarios
Chinmai Sai
Chinmai Sai el 11 de Nov. de 2023
Yes, total. In other words "sum"

Iniciar sesión para comentar.

Respuesta aceptada

the cyclist
the cyclist el 11 de Nov. de 2023
R = [1; 3; 4; 1; 1; 3];
Z = [3; 2; 1; 3; 2; 2];
E = [0.5; 0.4; 0.3; 0.1; 0.5; 0.4];
tbl = table(R,Z,E)
tbl = 6×3 table
R Z E _ _ ___ 1 3 0.5 3 2 0.4 4 1 0.3 1 3 0.1 1 2 0.5 3 2 0.4
groupsummary(tbl,["R","Z"],"sum","E")
ans = 4×4 table
R Z GroupCount sum_E _ _ __________ _____ 1 2 1 0.5 1 3 2 0.6 3 2 2 0.8 4 1 1 0.3

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by