Time averaging denoising signal I would like to use time averaging technique for denoising vibration signal, using the below function, how do we choose the appropriate parameters D and N for optimal denoising  !
% sigav.m - signal averaging

%
% y = sigav(D, N, x)
%
% D = length of each period
% N = number of periods
% x = row vector of length at least ND (doesn't check it)
% y = length-D row vector containing the averaged period
% It averages the first N blocks in x
function y = sigav(D, N, x)
  y = 0;
  for i=0:N-1,
      y = y + x((i*D+1) : (i+1)*D);       % accumulate i-th period
  end
  y = y / N;
Your approach will only denoise anything, if your signal is actual periodic. That's typically the case if you use a sine wave or periodic random noise or sweep as an excitation signal for a measurement. It can also work, if you vibration source is periodic (e.g. an engine running an constant rpm).
In this case $D$ should be chosen to represent EXACTLY one period. $N$ is simply determined by the length of your data set. The longer the better.
This works best if the excitation clock and acquisition clock are phase locked, i.e. derived from the same clock source. If that's not the case, it may be required to do some sort of clock recovery or clock tracking first.