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