Filter löschen
Filter löschen

Grouping the data of two variables by sum

2 Ansichten (letzte 30 Tage)
Chinmai Sai
Chinmai Sai am 11 Nov. 2023
Beantwortet: the cyclist am 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 Kommentare
Chinmai Sai
Chinmai Sai am 11 Nov. 2023
Yes, total. In other words "sum"

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

the cyclist
the cyclist am 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

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB 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!

Translated by