function rebv = RebinVector(vec,nr)

nx = length(vec);

rebv = zeros(fix(nx/nr),1);


 x = 1; 
 ri = 1;
 while x < nx-nr
    sum = 0;
    to = x+nr-1;
    for i=x:to
       %fprintf(1,'ri=%d, x=%d, i=%d\n',ri,x,i);
       sum = sum + vec(i);
    end
    rebv(ri) = sum/nr;
    ri = ri + 1;
    x =  x + nr;
  end % of a row

