필터 지우기
필터 지우기

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
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?
Luigi Treccozzi
Luigi Treccozzi 2018년 7월 15일
I don't know what that number is before I aggregate. I thought at this solution but I don't know how can I count them. Anyway, my question is: How can I aggregate some rows in a matrix? Look at the example. Of course I have some more complex matrix on which to work

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Sparse Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by