フィルターのクリア

Grouping the data of two variables by sum

2 ビュー (過去 30 日間)
Chinmai Sai
Chinmai Sai 2023 年 11 月 11 日
回答済み: the cyclist 2023 年 11 月 11 日
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 件のコメント
Chinmai Sai
Chinmai Sai 2023 年 11 月 11 日
Yes, total. In other words "sum"
Walter Roberson
Walter Roberson 2023 年 11 月 11 日

サインインしてコメントする。

採用された回答

the cyclist
the cyclist 2023 年 11 月 11 日
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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by