How can i group a the elements of a Matrix and returns an aggregation function in SQL style?
Show older comments
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 Comments
Luigi Treccozzi
on 15 Jul 2018
Rik
on 15 Jul 2018
I don't understand your question, but if you already have the sum, can't you just divide that by the number of elements?
Luigi Treccozzi
on 15 Jul 2018
Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!