I have a 20x1 vertical matrix. I want to take the averages of the pairs in order and display them in another matrix. How?
조회 수: 4 (최근 30일)
이전 댓글 표시
To elaborate. I want to average the first and second numbers, third and fourth numbers, etc.. and display them again in a 10x1 matrix.
댓글 수: 0
채택된 답변
Image Analyst
2012년 6월 28일
편집: Image Analyst
2012년 6월 28일
Try this:
m = randi(5, [20 1]) % Generate sample data
% Reshape to a 10 by 2 array.
reshapedMatrix = reshape(m, [10,2])
% Get the means going across columns (within a row)
meansOfPairs = mean(reshapedMatrix, 2)
댓글 수: 0
추가 답변 (1개)
Honglei Chen
2012년 6월 28일
편집: Honglei Chen
2012년 6월 28일
x = rand(20,1);
y = transpose(mean(reshape(x,2,10)))
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!