Effacer les filtres
Effacer les filtres

Grouping the data of two variables by sum

2 vues (au cours des 30 derniers jours)
Chinmai Sai
Chinmai Sai le 11 Nov 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 commentaires
Chinmai Sai
Chinmai Sai le 11 Nov 2023
Yes, total. In other words "sum"
Walter Roberson
Walter Roberson le 11 Nov 2023

Connectez-vous pour commenter.

Réponse acceptée

the cyclist
the cyclist le 11 Nov 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

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB 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!

Translated by