n = 0:7999
x = cos(2*pi*500*n) + cos(2*pi*1500*n) + cos(2*pi*3500*n)

window = 10

n_avg = 0:window
avg = 0;
for k = 0:window
    [x_shifted , n2] = sigshift(x,n,-k); 
    [avg, n_avg] = sigadd(avg, n_avg, x_shifted, n2);
end

stem(n_avg,avg)
