% Routine to illustrate and verify HW 2 from ECE 565 (Spring 2008) N_t = 10000; N = 1000; M = 500; A = 0.1; B = 1; n = [1:N_t]'; xs = A*sin((2*pi/N)*n); xr = B*randn(N_t,1); y = zeros(N_t,1); x = xs + xr; for i = M:N_t y(i) = mean(x(i-(M-1):i)); end figure(1) subplot(2,1,1) plot(n,xd) xlabel('n') ylabel('x_d[n]') subplot(2,1,2) plot(n,xr) xlabel('n') ylabel('x_r[n]') figure(2) subplot(2,1,1) plot(n,x) xlabel('n') ylabel('x[n]') subplot(2,1,2) plot(n,y) xlabel('n') ylabel('y[n]')