MATLAB: I have a 20×1 vertical matrix. I want to take the averages of the pairs in order and display them in another matrix. How

matrices

To elaborate. I want to average the first and second numbers, third and fourth numbers, etc.. and display them again in a 10×1 matrix.

Best Answer

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)