fork download
  1. f = @(x)mean(reshape(~~(1:4)'*x,[],4)(:,2:3)(:))
  2.  
  3. f([1, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 38])
  4.  
  5. f( [1, 3, 5, 7, 9, 11, 13, 15, 17])
Success #stdin #stdout 0.68s 121792KB
stdin
Standard input is empty
stdout
f =

@(x) mean (reshape (!!(1:4)' * x, [], 4) (:, 2:3) (:))

ans =  6.5000
ans =  9