function [y] = mids(x) n = length(x); y = (x(1:n-1) + x(2:n))/2;