A causal N-point moving-average filter has impulse response h[n] = (u[n]-u[n-N])/N.
a. Determine a constant coefficient difference equation that has impulse response h[n].
b. Write a MATLAB function that will compute the parameters necessary to implement an N-point moving-average filter using
MATLAB filter command. That is, your function should output filter vectors b and a given a scalar input N.
c. Test your filter and MATLAB code by filtering a length-45 input defined as x[n] = cos(πn/5) + δ[n - 30] - δ[n - 35]. Separately plot the results for N = 4, N = 8, and N = 12. Comment on the filter behavior.
d. Problem 3.M-7 introduces linear interpolation filters, for use following an up-sample by N operation. Within a scale factor, show that a cascade of two N-point moving-average filters is equivalent to the linear interpolation filter. What is the scale factor difference? Test this idea with MATLAB. Create x[n] = cos(n) for (0 ≤ n ≤ 9). Upsample x[n] by N = 10 to create a new signal xup[n]. Design an N = 10 moving-average filter. Filter xup[n] twice and scale to produce y[n]. Plot the results. Does the output from the cascaded pair of moving-average filters linearly interpolate the upsampled data?