micro7311
Junior Member level 2
Hi, in the below code I am generating a signal with a center frequency of 0MHz, +/- 10 MHz. I am wondering how to shift the entire spectrum to a center frequency of 20 MHz, +/-10 MHz (10 MHz to 30 MHz). What I am trying to do is take the final spectrum and multiply it by a complex exponential. No matter what time value I choose in the exponential, the spectrum doesn't move from fc = 0 MHz. Am I approaching this correctly?
Code:
nFFTSize = 64;
subcarrierIndex = [-26:-1 1:26];
nBit = 1000;
ip = rand(1,nBit) > 0.5;
nBitPerSymbol = 52;
nSymbol = ceil(nBit/nBitPerSymbol);
ipMod = 2*ip - 1;
ipMod = [ipMod zeros(1,nBitPerSymbol*nSymbol-nBit)];
ipMod = reshape(ipMod,nSymbol,nBitPerSymbol);
st = [];
for ii = 1:nSymbol
inputiFFT = zeros(1,nFFTSize);
% assigning bits a1 to a52 to subcarriers [-26 to -1, 1 to 26]
inputiFFT(subcarrierIndex+nFFTSize/2+1) = ipMod(ii,:);
% shift subcarriers at indices [-26 to -1] to fft input indices [38 to 63]
inputiFFT = fftshift(inputiFFT);
outputiFFT = ifft(inputiFFT,nFFTSize);
% adding cyclic prefix of 16 samples
outputiFFT_with_CP = [outputiFFT(49:64) outputiFFT];
st = [st outputiFFT_with_CP];
end
st2 = st*exp(2*pi*20*i*.0000032);
scatterplot(st2), grid;