f = @(x)mean(reshape(~~(1:4)'*x,[],4)(:,2:3)(:)) f([1, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 38]) f( [1, 3, 5, 7, 9, 11, 13, 15, 17])
Standard input is empty
f = @(x) mean (reshape (!!(1:4)' * x, [], 4) (:, 2:3) (:)) ans = 6.5000 ans = 9
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!