OFDMA & SC-FDMA performance analysis

by

 

performance evaluation for OFDMA and SC-FDMA LTE multiple access techniques.

ofdma.m
%//////// OFDMA ////////////
% No. of Subcarriers
NS = 512;
% Input Generation
x = rand(1,NS)>0.5;
fftlength = 512;
nd = 6;
BW = 5e6;
FS = 2*BW; % Sampling Frequency
% Conversion of data from serial to parallel 
 p = series2parallel(x,NS);
% M ary Modulation of PSK and QAM
M = 2; 
X = 0;
for count1 = 2:1:7;
if (M==2||M==4||M==16||M==64)
M = M+X;
% M-ary modulation for producing y.
if(M<=8)
% Modulation for PSK
y = modulate(modem.pskmod(M),p);
else
% Modulation for QAM
y = modulate(modem.qammod(M),p);
end
ylen = length(y);
%Applying Mapping
q_out = ofdma_mapping(y,ylen);
% Apply IFFT operation
outifft = ifft(q_out);
% Cyclic Prefix Addition
cp(count1,:) = cyclicpad(outifft,64);
% Length of CP
cplength = length(cp);
% Conversion of data from parallel to serial 
out = reshape(cp(count1,:),1,cplength);
% Signal transmits through AWGN channel.
ynoisy = awgn(out,100,'measured');
% Addition of Rayleigh Fading 
c = rayleighchan(1/1000,100,[0 2e-5],[0 -9]);
rf = filter(c,ynoisy); 
% Conversion of data from serial to parallel
p2 = series2parallel(rf,cplength);
re_par = real(p2);
% Remove cyclic prefix
rcp(count1,:) = decyclicpad(p2,64);
rcplength = length(rcp);
% FFT
zzfft = fft(rcp(count1,:),fftlength);
%Apply Demapping
qq_out = ofdma_demapping(zzfft,fftlength);
outfft = qq_out;
% %Applying IFFT
% zfft = ifft(qq_out);
if (M<=8)
% Demodulation of PSK at Reciever
z=demodulate(modem.pskdemod(M),outfft);
else
% Demodulation of QAM at Reciever
z=demodulate(modem.qamdemod(M),outfft);
end
% Conversion of data from parallel to serial
xdash = reshape(z,1,NS)
berr = 0 ;
for a = 1:1:NS;
if (xdash(:,a) == x(:,a))
berr = 0;
else
berr = berr+1;
end
end
tberr(count1,:) = berr;
Eb_No = 0:1:NS-1;
Eb_No = 0.4*Eb_No;
if(M<=8)
ber(count1,:) = berawgn(Eb_No,'psk',M,'nondiff');
Pe(count1,:) = erfc(sqrt(0.9*Eb_No)*sin(pi/M));
else
ber1(count1,:) = berawgn(0.9*Eb_No,'qam',M);
Pe(count1,:) = 2*((1-(1/sqrt(M)))*erfc(sqrt((1.5*Eb_No)/(M-1))));
end
for init = 1:1:32
switch M
end
end
end
M= 2^count1;
end
figure()
% Plot SNR and BER 
semilogy(Eb_No,ber(2,:),'k',Eb_No,ber(3,:),'g',Eb_No,ber1(5,:),'b',Eb_No,ber1(7,:),'r');
axis([0 25 0.0001 1]);
xlabel('SNR [dB]')
ylabel('BER')
legend('BPSK','QPSK','16-QAM','64-QAM')
title('OFDMA')
figure()

% Plot Error Probability
semilogy(Eb_No,Pe(2,:),'k',Eb_No,Pe(3,:),'r',Eb_No,Pe(5,:),'b',Eb_No,Pe(7,:),'g');
axis([0 50 0.0001 1]);
xlabel('SNR [dB]')
ylabel('Probability of Error')
legend('BPSK','QPSK','16-QAM','64-QAM')
title('OFDMA')
h = spectrum.periodogram;
figure()
HS = psd(h,outifft,'SpectrumType','twosided','NFFT',NS,'FS',FS);
plot(HS)
xlabel('Sampling Frequency (2BW) in MHz')
ylabel('Power Spectral Density [dBm/Hz]')
title('OFDMA')
grid off;



%///////////SC-FDMA///////

% No. of Subcarriers
NS = 512;
% Input Generation
x = rand(1,NS)>0.5;
fftlength = 512;
nd = 6;
BW = 5e6;
FS = 2*BW; % Sampling Frequency
% Conversion of data from serial to parallel
par2 = series2parallel(x,NS);
% M ary Modulation of PSK and QAM
M = 2;
X = 0;
for count1 = 2:1:7;
if (M==2||M==4||M==16||M==64)
M = M+X
% M-ary modulation for producing y.
if(M<=8)
% Modulation for PSK
y=modulate(modem.pskmod(M),par2);
else
% Modulation for QAM
y=modulate(modem.qammod(M),par2);
end
%Apply FFT operation
out_fft = fft(y,fftlength);
%Applying Mapping
q_out = scfdma_mapping(out_fft,fftlength);
% Apply IFFT operation
out_ifft = ifft(q_out);
% Cyclic Prefix Addition
cp(count1,:) = cyclicpad(out_ifft,64);
cplength = length(cp);
% Conversion of data from parallel to serial
out = reshape(cp(count1,:),1,cplength);
% Signal transmits through an AWGN channel.
ynoisy = awgn(out,100,'measured');
% Rayleigh Fading
c = rayleighchan(1/1000,100,[0 2e-5],[0 -9]);
rf = filter(c,ynoisy);
% Conversion of data from serial to parallel
p = series2parallel(rf,cplength);
re_par = real(p);
% Remove cyclic prefix
rcp(count1,:) = decyclicpad(p,64);
len_rcp = length(rcp);
% Applying FFT operation
cpfft = fft(rcp(count1,:),fftlength);
%Applying Demapping
qq_out = scfdma_demapping(cpfft,fftlength);
%Applying IFFT operation
out_fft = ifft(qq_out);
if (M<=8)
% Demodulation of PSK
z=demodulate(modem.pskdemod(M),out_fft);
else
% Demodulation of QAM
z=demodulate(modem.qamdemod(M),out_fft);
end
% Conversion of data from parallel to serial
xdash = reshape(z,1,NS)
berr = 0 ;
for a = 1:1:NS;
if (xdash(:,a) == x(:,a))
berr = 0;
else
berr = berr+1;
end
end
tberr(count1,:) = berr;
Eb_No = 0:1:NS-1;
if(M<=8)
ber(count1,:) = berawgn(0.9*Eb_No,'psk',M,'nondiff');
Pe(count1,:) = erfc(sqrt(2*Eb_No)*sin(pi/M));
else
ber1(count1,:) = berawgn(0.9*Eb_No,'qam',M);
Pe(count1,:) = 2*((1-(1/sqrt(M)))*erfc(sqrt((1.5*Eb_No)/(M-1))));
end
for init = 1:1:32
switch M
end
end
end
M= 2^count1;
end
figure()
% Plot SNR and BER
semilogy(Eb_No,ber(2,:),'*-r',Eb_No,ber(3,:),'k',Eb_No,ber1(5,:),'b',Eb_No,ber1(7,:),'g');
axis([0 25 0.0001 1]);
xlabel('SNR [dB]')
ylabel('BER')
legend('BPSK','QPSK','16-QAM','64-QAM')
title('SC-FDMA')
figure()

% Plot Error Probability
semilogy(Eb_No,Pe(2,:),'-k',Eb_No,Pe(3,:),'-r',Eb_No,Pe(5,:),'-b',Eb_No,Pe(7,:),'-c');
axis([0 50 0.0001 1]);
xlabel('SNR [dB]')
ylabel('Probability of Error')
legend('BPSK','QPSK','16-QAM','64-QAM')
title('SC-FDMA')
h = spectrum.periodogram;
figure()
HS = psd(h,out_ifft,'SpectrumType','twosided','NFFT',NS,'FS',FS);
plot(HS)
xlabel('Sampling Frequency (2BW) in MHz')
ylabel('Power Spectral Density [dBm/Hz]')
title('SC-FDMA')
grid off;


Serial to Parallel:
function y = series2parallel(x,NS)
L=length(x);
q=floor(L/NS);
newvec=zeros(NS,q);
for i=1:q
newvec(1:NS,i)=x((1+(i-1)*NS):i*NS);
end
y=newvec;


Cyclic Prefix:
function y=cyclicpad(X,L)
N=length(X(:,1));
N-L+1
Y=[X(N-L+1:N,:);X];
y=Y;

Remove Cyclic Prefix:
function y=decyclicpad(X,L)
N=length(X(:,1));
Y=X(L+1:N,:);
y=Y;


Mapping:
function [iout,qout]=crmapping(idata,qdata,fftlength,nd);
iout=zeros(fftlength,nd);
qout=zeros(fftlength,nd);
iout(2:27,:)=idata(1:26,:);
qout(2:27,:)=qdata(1:26,:);
iout(39:64,:)=idata(27:52,:);
qout(39:64,:)=qdata(27:52,:);



 Demapping:
function [iout,qout]=crdemapping(idata,qdata,fftlength,nd);
iout(1:26,:)=idata(2:27,:);
qout(1:26,:)=qdata(2:27,:);
iout(27:52,:)=idata(39:64,:);
qout(27:52,:)=qdata(39:64,:);



PAPR:
BPSK:
function paprSCFDMA()
dataType = 'B-PSK'; % Modulation format.
NS = 512; % Number of total subcarriers.
Symbols = 16; % Data block size.
Q = NS/Symbols; % Bandwidth spreading factor of SC-FDMA.
BW = 5e6; % System bandwidth.
Ts = 1/BW; % sampling rate.
osf = 4; % Oversampling factor.
Nsub = NS;
Fsub = [0:Nsub-1]*BW/Nsub; % Subcarrier spacing of OFDMA.
Runs = 1e3; % Number of iterations.

papr1 = zeros(1,Runs); % Initialize the PAPR results for sc-fdma.
papr3 = zeros(1,Runs); % Initialize the PAPR results for OFDMA

for n = 1:Runs,
% Generate random data.
if dataType == 'B-PSK'
tmp = round(rand(Symbols,2));
tmp = tmp*2 - 1;
data = (tmp(:,1) + j*tmp(:,2))/sqrt(2);
elseif dataType == '16QAM'
dataSet = [-3+3i -1+3i 1+3i 3+3i ...
-3+i -1+i 1+i 3+i ...
-3-i -1-i 1-i 3-i ...
-3-3i -1-3i 1-3i 3-3i];

dataSet = dataSet / sqrt(mean(abs(dataSet).^2));
tmp = ceil(rand(Symbols,1)*16);
for k = 1:Symbols,
if tmp(k) == 0
tmp(k) = 1;
end
data(k) = dataSet(tmp(k));
end
data = data.';
end

% Convert data to frequency domain.
Z1 = fft(data);
Z2 = fft(data);
% Initialize the subcarriers.
Y1 = zeros(NS,1);
Y2 = zeros(NS,1);
% Subcarrier mapping for SC-FDMA
Y1(1:Q:NS) = Z1;
Y2(1:Symbols) = Z2;
% Convert data back to time domain.
y1 = ifft(Y1);
y2 = ifft(Y2);
% OFDMA modulation.
% Time range of the OFDMA symbol.
t = [0:Ts/osf:Nsub*Ts];
y3 = 0;
for k = 1:Symbols,
y3= y3 + data(k)*exp(j*2*pi*Fsub(k)*t);
end

% Calculate PAPR.
papr3(n) = 10*log10(max(abs(y3).^2) / mean(abs(y3).^2));
papr1(n) = 10*log10(max(abs(y1).^2) / mean(abs(y1).^2));
papr2(n) = 10*log10(max(abs(y2).^2) / mean(abs(y2).^2));
end

% Plot CCDF.
figure ()
[N,Z3] = hist(papr3, 100);
[N,Z1] = hist(papr1, 100);
[N,Z2] = hist(papr2, 100);
semilogy(Z1,1-cumsum(N)/max(cumsum(N)),'b')
hold on
semilogy(Z3,1-cumsum(N)/max(cumsum(N)),'black')
hold off
title ('PAPR of SC-FDMA and OFDMA for BPSK')
xlabel ('PAPR[dB]')
ylabel ('{PAPR(PAPR>PAPR0)}')
grid off;
% Save data.
save paprSCFDMA

QPSK:
if dataType == 'QPSK'
tmp = round(rand(Symbols,4));
tmp = tmp*2 - 1;
data = (tmp(:,1) + j*tmp(:,2))/sqrt(2);


16-QAM:
elseif dataType == '16QAM'
dataSet = [-3+3i -1+3i 1+3i 3+3i ...
-3+i -1+i 1+i 3+i ...
-3-i -1-i 1-i 3-i ...
-3-3i -1-3i 1-3i 3-3i];





64-QAM:
elseif dataType == '64QAM'
dataSet = [-5+5i -1+5i 1+5i 5+5i ...
-5+i -1+i 1+i 5+i ...
-5-i -1-i 1-i 5-i ...
-5-5i -1-5i 1-5i 5-5i];







Contact us