# OFDM signal construction using MATLAB

#### meteturedi

Joined Oct 24, 2017
5
Hello,

I have been trying to implement an OFDM logic in MATLAB (without any cyclic prefix, guard interval or pilot carriers yet) and have been failing to reconstruct the time domain signal following the IFFT for transmission, at least based on my understanding of what it should look like. Please see the code I have been using below;

Code:
modOrder = 16; % 16-QAM
numSubcarriers = 64; % 64-point IDFT so same number of subcarriers
numBits = numSubcarriers*log2(modOrder);
srcBits = randi([0,1],numBits,1); % Generate random bits for one OFDM symbol to carry

qamModOut = qammod(srcBits,modOrder,"InputType","bit","UnitAveragePower",true);
ofdmModOut = ofdmmod(qamModOut,64,0);

channelWidth = 20e6;
deltaF = channelWidth/numSubcarriers;
Ts = 1/deltaF;
iVal = 2e-10;
fc = 2.4e9;
t = 0:iVal:Ts-iVal;

for i=1:64
y(i,:) = ofdmModOut(i)*sqrt(numSubcarriers/Ts)*...
sinc((pi*numSubcarriers/Ts)*(t-(i-1)*Ts/numSubcarriers));
end
ySum=(1/numSubcarriers)*sum(y,1);

Ixt = real(ySum);
Qxt = imag(ySum);

timeDomainBB = (Ixt.*cos(2*pi*fc.*t))-(Qxt.*sin(2*pi*fc.*t));
As you can see above, I generate stream of random bits, 16-QAM modulate it and OFDM modulate with MATLAB built-in functions. I use a 20MHz channel width so deltaF=20e6/64=0.3125MHz and center frequency of 2.4GHz. I then try to convert it x(t) from x[n] where x[n] would be the samples of the complex envelope with the last for loop above and the I-Q modulation step following that.

When I compare the result timeDomainBB with a passband version of it that I build using the code below;

Code:
for i=1:length(qamModOut)
alltimeDomainPB(i,:) = real(qamModOut(i)* ...
exp(complex(0,1)*(2*pi*((2.39e9+(deltaF/2))+((i-1)*deltaF))*t)));
end
timeDomainPB = sum(alltimeDomainPB,1);
The results don't match perfecly as you can see below;

The red waveform is the baseband version and the blue is the passband. Also the spectrum of the baseband doesn't appear to be correct;

Where the yellow figure extends well beyond the expected frequency range between 2.39-2.41GHz.

Can anyone help me with what I might be doing worng with the construction of the time domain signal (if that is the problem..)?