Вы находитесь на странице: 1из 6

SIMULATION

OF OFDM
Simulation using
MATLAB under practical
conditions
Kishan P B

MATLAB CODE:
%
%
%
%
%
%
%
%
%
%
%
%

OFDM.m
Written by: KISHAN P B
4th year B.E student,
Dept. of ECE, PESIT
No.of Carriers: 64
coding used: Convolutional coding + trellis
Single frame size: 96 bits
Total no. of Frames: 100
Modulation: 16-QAM
No. of Pilots: 4
Cylic Extension: 25%(16 bits)
Final Packet size: 80

%%
% Your wish to use the following
% close all
% clear all
% clc
tt = tic();
%%
% Initialisations
Single_frame_size = 96;
Total_no_of_Frames = 100;
scatter_plot_frame = 48;
x=1; %Frame distinction
xx=1; %Scatter plot distinction
si=1; %for BER rows
pilt=3+3j; % Pilot complex insertion data
no_of_Carriers = 64; % Data to be transmitted without CP/CE
initial_test_snr = 0;
snr_step_size = 2;
final_test_snr = 50;
BER = zeros( Total_no_of_Frames ,floor(
(final_test_snr+snr_step_size)/snr_step_size )); % To store final Bit error
rate results; here it is 100*26
no_of_pilots = 4;
no_of_data_without_carriers = (Single_frame_size*2/no_of_pilots) +
no_of_pilots; % 52 in this case ; derived from line "x"
cyclic_extension = 16;
choice_snr = 14; % choose a valid snr value to plot the result ---- see below
%%
% Generating data
t_data = floor(2*rand(1,Single_frame_size*Total_no_of_Frames));
t_rxed_data=zeros(2,Single_frame_size*Total_no_of_Frames);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%HERE THE CORE CODE EXISTS%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IF YOU ARE IMPRESSED BY THE RESULTS AND
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NEED THE CODE, THEN MAIL ME!!!
%%
% Time averaging for optimum results
ber = zeros(1,26);
BER = BER';
for col=1:26;
%%%change if SNR loop Changed
ber(1,col)=ber(1,col)+sum(BER(col,:));
end
ber=ber./(Single_frame_size*Total_no_of_Frames*log2(M)); % Normalisation

%%%
RESULTS
%%
% Scatter Plot
% Create scatter plot of noisy signal and transmitted
% signal on the same axes.
h = scatterplot(scatter_plot_requirement(2,:),1,0,'g.');
hold on;
scatterplot(scatter_plot_requirement(1,:),1,0,'k*',h);
choice_snr = num2str(choice_snr);
title_print = strcat('received Signal of SNR = ',choice_snr);
title(title_print);
legend('Noisy received Signal','Signal Constellation');
axis([-5 5 -5 5]); % Set axis ranges.
hold off;
%%
% Plot for comparison between original signal wrt processed rxed signal
figure;
space = 10;
t = 1:space:Single_frame_size*Total_no_of_Frames;
subplot(211);
y =
[t_rxed_data(1,1:space:Single_frame_size*Total_no_of_Frames);t_data(1:space:Si
ngle_frame_size*Total_no_of_Frames)]';
h = stem(t,y);
set(h(1),'MarkerFaceColor','blue')
set(h(2),'MarkerFaceColor','red','Marker','square')
title('Blue --> Processed received Signal at SNR = 50 & Red --> Original
generated data');
subplot(212);
y =
[t_rxed_data(2,1:space:Single_frame_size*Total_no_of_Frames);t_data(1:space:Si
ngle_frame_size*Total_no_of_Frames)]';
h = stem(t,y);
set(h(1),'MarkerFaceColor','blue')
set(h(2),'MarkerFaceColor','red','Marker','square')

title_print = strcat('Blue --> Processed received Signal of SNR =


',choice_snr,' & Red --> Original generated data');
title(title_print);
%%
% BER vs SNR graph
figure;
i=0:2:16;
theoryBer = (1/4)*3/2*erfc(sqrt(4*0.1*(10.^(i/10))));
semilogy(i,theoryBer,'bs-','LineWidth',2);
hold on
semilogy(i,ber(1:9),'mx-','LineWidth',2);
title('BER vs SNR');
ylabel('Normalised BER');
xlabel('SNR (dB)');
grid on
legend('theory', 'simulation');

%%
toc(tt);

% Processing time on my laptop was ~2 seconds

RESULTS IN GRAPHS:
received Signal of SNR =14
5
Noisy received Signal
Signal Constellation

4
3

Quadrature

2
1
0
-1
-2
-3
-4
-5
-5

0
In-Phase

FIGURE 1: CONSTELLATION DIAGRAM

Blue --> Processed received Signal at SNR = 50 & Red --> Original generated data
1

0.5

1000

2000

3000

4000

5000

6000

7000

8000

9000

10000

Blue --> Processed received Signal of SNR =14 & Red --> Original generated data
1

0.5

1000

2000

3000

4000

5000

6000

7000

8000

9000

10000

FIGURE 2: ORIGINAL DATA AND RECEIVED DATA

BER vs SNR

10

theory
simulation
-2

Normalised BER

10

-4

10

-6

10

-8

10

-10

10

8
SNR (dB)

10

12

14

16

FIGURE 3: THEORETICAL AND SIMULATED BER CURVES

REFERENCES:
1. Kishan P B, Orthogonal Frequency Division Multiplexing, www.academia.edu 2014.
2. MatLab help

Вам также может понравиться