This example shows how to upsample a signal and apply a lowpass interpolation filter with interp. Upsampling by L inserts L - 1 zeros between every element of the original signal. Upsampling can create imaging artifacts. Lowpass filtering following upsampling can remove these imaging artifacts. In the time domain, lowpass filtering interpolates the zeros inserted by upsampling.
Create a discrete-time signal whose baseband spectral support is . Plot the magnitude spectrum.
F = [0 0.250 0.500 0.7500 1]; A = [1.0000 0.5000 0 0 0]; Order = 511; B = fir2(Order,F,A); [Hx,W] = freqz(B,1,8192,'whole'); Hx = [Hx(4098:end) ; Hx(1:4097)]; omega = -pi+(2*pi/8192):(2*pi)/8192:pi; plot(omega,abs(Hx)) xlim([-pi pi]) xlabel('Radians/Sample') ylabel('Magnitude')
Upsample the signal and apply a lowpass filter to remove the imaging artifacts. Plot the magnitude spectrum.
y = interp(B,2); [Hy,W] = freqz(y,1,8192,'whole'); Hy = [Hy(4098:end) ; Hy(1:4097)]; hold on plot(omega,abs(Hy),'r','linewidth',2) legend('Original Signal','Upsampled Signal')
Upsampling still contracts the spectrum, but the imaging artifacts are removed by the lowpass filter.