MATLAB: Counting n subsequent element of an array

matrix manipulation

say i have an array a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
is there a easy way to add say n=3 elements at a time and form another array b. that is elements of b will be as follows:
b = [1+2+3, 2+3+4, 3+4+5, 4+5+6, 5+6+7,6+7+8,7+8+9, 8+9+10];

Best Answer

b = conv(a,[1 1 1],'valid')