I have a 20x1 vertical matrix. I want to take the averages of the pairs in order and display them in another matrix. How?
2 次查看(过去 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!