Upsampling Baseband Signal and Passband Signal.




This post is a continuation of the post Converting signal from Complex Baseband to Passband. In this post, I'll be discussing the difference between the two MATLAB functions upsample(.) and resample(.) by upsampling a baseband signal and passband signal. 



 Let's create a baseband signal in MATLAB

x=-5:5;
y=inline('-(x-10)')
f1=[zeros(1,27) y(x) zeros(1,26)];
f1=fftshift(f1);
f2=[ones(1,11),zeros(1,53)];
fbase = f1+1j*f2;           
%Baseband signal in freq domain
xt  = ifft(fbase);           %Baseband signal in time domain

Baseup  = upsample(xt,4);fBaseup = fft(Baseup,64*4);     
Baseup2  = resample(xt,4,1); fBaseup2 = fft(Baseup,64*4);     


Here, the upsample function introduces three zeros between each sample in time domain, while the resample function interpolates and fills in those time domain values which were zeros during upsampling. In effect, the sampling frequency increases by four in both cases.


figure;
subplot(311);plot(-32:31,fftshift(abs(fbase)));
title('Baseband - (-fs/2 to fs/2)');
subplot(312);plot(-128:127,fftshift(abs(fBaseup)));
title('Baseband - Upsample')  
subplot(313);plot(-128:127,fftshift(abs(fBaseup2)));
title('Baseband - resample')

Let's have a look at the plots:



The subplot(1) shows the baseband signal sampled at fs = 64, hence we are able to view the signal from -fs/2 to fs/2. The periodicity of the baseband signal is visible in subplot(2) which was sampled at fs = 256Hz, so we can see that the spectrum repeats with period fs = 64. No changes are visually observable between using upsample (ref.  subplot(2)) and resample (ref. subplot(3)) functions for the given baseband signal.



Let's repeat the same for a Passband signal.

The passband signal was obtained by translating the baseband signal by fm =15; 

fm = 15;       %Passband frequency

x_real = real(xt);
x_imag = imag(xt);
modsin = sin(2*pi*(fm/fs)*(0:length(xt)));
modcos = cos(2*pi*(fm/fs)*
(0:length(xt)));
Passbandsignal = x_real.*modcos - x_imag.*modsin;


fpass = fft(Passbandsignal,64);
Passup = upsample(Passbandsignal,4);
fpassup=fft(Passup,64*4);
Passup2 = resample(Passbandsignal,4,1);

fpassup2 = fft(Passup2,64*4);

figure;
subplot(311);plot(-32:31,fftshift(abs(fbase)));
title('Baseband - (-fs/2 to fs/2)');
subplot(312);plot(-128:127,fftshift(abs(fpassup)));
title('Passband - upsample')  
subplot(313);plot(-128:127,fftshift(abs(fpassup2)));

title('Passband - resample')




In subplot(2), we can clearly see the periodicity of the passband signal. This plot was obtained by upsampling the passband signal in time domain by 4, so that we can observe signals from -fs'/2 to fs'/2 (here fs' = 64*4 ) . 

In subplot(3), we can see that resample(.) function not only upsamples the signal but also applies a filter, to filter signals centered at fs'=0 and multiples of fs'= 64*4.  Thus, resample() function helps us to remove unwanted signal components at frequencies n*fs, where n ~= p.
Note: (p= upsample factor, fs'= upsampled frequency, fs = initial sampling frequency, fs' = p*fs).



No comments:

Post a Comment