MATLAB: Mean of elements of array

mean of array

Hi,
I have an array of length 8000. I want to create another array by taking the mean of 10 elements at a time. I could do this using for loop. However, using for loop is time consuming and would like to know if there is any alternative for this.
Any help is highly appreciated.
array = rand(1,8000);
mean_array = zeros(1,800);
for i=1:800
mean_array(1,i) = mean(array(1,((i-1)*10+1):i*10));
end

Best Answer

mean_array = mean(reshape(array,10,[]));