Hint: I found https://it.mathworks.com/matlabcentral/answers/156577-how-to-sum-group-values-in-a-matrix-based-on-their-index-values-in-first-column This gives me the sum. How can I modify according to my needs (simple mean)
How can i group a the elements of a Matrix and returns an aggregation function in SQL style?
1 回表示 (過去 30 日間)
古いコメントを表示
Hi guys! I'll show you an example of what I'd like to do: I have a matrix A
A = [
1 2 3
2 1 2
1 2 6
2 1 4
]
Suppose I want to group by the first two columns and return for each of those the mean value of the third column. The output matrix will be
A_group = [
1 2 4.5
2 1 3
]
Is there any function that implements such a functionality? Thanks
3 件のコメント
Rik
2018 年 7 月 15 日
I don't understand your question, but if you already have the sum, can't you just divide that by the number of elements?
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!