change sliding window to standard method in Matlab