# Multiply FS Coefficients by 0 or 1 to get Low Pass Filter?

I have written a bit of code to upsample and interpolate a sample waveform in MATLAB. It's at the point where I have taken a signal, upsampled it 2x and filled in the gaps with 0's, and then I found the fourier series coefficients. I know I need to choose which coefficients to multiply by 0 and which to multiply by 1 in order to get a low-passed signal which I will then perform an inverse Fourier Transform on, and this will give me back my interpolated upsampled signal.

First of all - why do I need to low pass this signal? I suppose I kind of added period information my bringing in those 0's and upsampling the signal, but I don't understand how to find a cutoff for this ideal lowpass I need, and how to translate that cutoff frequency into 0's and 1's scaling my FS coefficients. I heard I need to multiply every other sample by 0, but I don't know why this would be correct.

Here is my code:

function [a] = UpSampler(x)
N=length(x);
Nu = 2*N;
xt=zeros(1,Nu);

for n=1:Nu
if(mod(n-1,2)==0)
xt(n)=x(1+(n-1)/2);
end
if(mod(n-1,2)==1)
xt(n)=0;
end
end

a = getDTFS(xt);

%multiply a coefficients by 0 or 1
%Perform Inverse FT to get interpolated signal

end


This is generally better visualized graphically. When you upsample a signal by inserting zeros between samples you get replicas of the original.

Let's take a simple bandpass signal and plot it. All I'm doing is taking noise and lowpass filtering it.

y = filter(fir1(255, 0.2), 1, randn(1, 1024));
plot(20*log10(abs(fft(y))))


Now let's plot an upsampled version. Usually L is used to denote the integer amount of upsampling in some texts, let's go with L = 2 & 4.

subplot(211)
plot(20*log10(abs(fft(upsample(y, 2)))))
subplot(212)
plot(20*log10(abs(fft(upsample(y, 4)))))


Notice how we now have 2 & 4 replicas of the original spectrum. This is effectively what happens when you upsample a signal.

Now the problem is I have spectral content in places that it shouldn't be. This is where lowpass filtering is used. In the time domain I'm filling in the zeros with interpolated data and in the frequency domain I'm trying to reduce that unwanted spectral content to finally arrive at these plots. Notice how the new filter cutoff frequencies are at fc/L since I've effectively increased the sample rate by fs*L. The original bandpass signal went up to 0.2*fs.

subplot(211)
plot(20*log10(abs(fft(filter(fir1(255, 0.10), 1, upsample(y, 2))))))
subplot(212)
plot(20*log10(abs(fft(filter(fir1(255, 0.05), 1, upsample(y, 4))))))