how can I get the mean of each two columns of a matrix ?
조회 수: 13 (최근 30일)
이전 댓글 표시
I have a big matrix and I want to get the average of each 2 columns,
Is there any function to do that ?
댓글 수: 0
채택된 답변
Star Strider
2016년 7월 8일
I’m not quite sure what you want.
See if this works for you:
M = randi(99, 10);
RM = reshape(M, 10, 2, [])
Mmean = mean(RM,2)
댓글 수: 2
Star Strider
2016년 7월 8일
I forgot a squeeze call. This will do what you want, and should work with any matrix:
M = randi(99, 10); % Create Data
RM = reshape(M, size(M,1), 2, []) % Reshape
Mmean = squeeze(mean(RM,2)) % Desired Result
추가 답변 (1개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!