Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Question about Matlab code in BER OFDM

Status
Not open for further replies.

Kareem Hamed

Newbie level 4
Newbie level 4
Joined
Oct 22, 2014
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
125
please i want from you explain why this code don't get the BER correctly
and how to add 2steps in this code
1-Compensate CFO in Reciever
2-delete effect the channel
and do think these 2 steps can change the code and gets the BER correctly


Code Matlab M - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
%%%%%%%%%%%%%%%%%%%%%
SP.FFTsize = 64;
% SP.inputBlockSize =16;
N=64;
SP.CPsize=20;
SP.subband = 0;
SP.numRun =10;%10^4;
% Constant CFOs values for each user 
SP.ep1=0.1; %
SP.ep2=-0.1;%-0.1;
SP.ep3=-0.05; %-0.05%;
SP.ep4=0.05;%0.05%;
numSymbols = SP.FFTsize;
% modtype='16QAM'; %'16QAM';modtyp=SP.modtype
ofdm;
% Constant CFOs
A1=exp((1*1i*2*pi*SP.ep1/(numSymbols))*(0:(numSymbols-1)));
A2=exp((1*1i*2*pi*SP.ep2/(numSymbols))*(0:(numSymbols-1)));
CT1=(eye(numSymbols))*diag(A1)*ifft(eye(numSymbols ));
CT2=(eye(numSymbols))*diag(A2)*ifft(eye(numSymbols ));
SP.SNR=0:5:30;
SP.channel=(1/sqrt(8))*(randn(2,8)+1i*randn(2,8))*(1/sqrt(2));%SP.channel=(1/sqrt(7))*(randn(4,7)+1i*randn(4,7))*(1/sqrt(2))
%AWGN channel
 
% H = fft(SP.channel(1,:),SP.FFTsize);
% H_channel2 = fft(SP.channel(2,:),SP.FFTsize);
for n = 1:length(SP.SNR) 
% rng('state',0)
% rng('state',0)
 
for k = 1:SP.numRun
 
SP.channel=(1/sqrt(8))*(randn(2,8)+1i*randn(2,8))*(1/sqrt(2));%SP.channel=(1/sqrt(7))*(randn(4,7)+1i*randn(4,7))*(1/sqrt(2))
%AWGN channel
 
H_channel1 = fft(SP.channel(1,:),SP.FFTsize);
H_channel2 = fft(SP.channel(2,:),SP.FFTsize);
% 
H = diag(fft(H_channel1,SP.FFTsize));
% A_channel2 = diag(fft(H_channel2,SP.FFTsize));
 
data1=randi([0 15],1,48);
data1=data1.';
inputSymbols1=qammod(data1,16);
I1=eye(N);
v_phi=1:4:64;
I1(:,v_phi)=[];
inputSymbols11=I1*inputSymbols1;
% inputSymbols=diag(I1*inputSymbols);
m2=4;
data2=randi([0 15],1,48);
data2=data2.';
inputSymbols2=qammod(data2,16);
I2=eye(N);
v_phi2=2:4:64;
I2(:,v_phi2)=[];
inputSymbols22=I2*inputSymbols2;
% OFDM User 1 
inputSymbols_freq = fft(inputSymbols11).'; 
%OFDM User 2
 
inputSymbols_freq2 = fft(inputSymbols22).'; 
TxSamples_u1= [inputSymbols_freq(numSymbols-SP.CPsize+1:numSymbols) inputSymbols_freq]; % TxSamples_ifdma_u1= [TxSamples_ifdma1(numSymbols-SP.CPsize+1:numSymbols) TxSamples_ifdma1];
 
%CP for User 2 
TxSamples_u2= [inputSymbols_freq2(numSymbols-SP.CPsize+1:numSymbols) inputSymbols_freq2 ]; % TxSamples_ifdma_u2= [TxSamples_ifdma2(numSymbols-SP.CPsize+1:numSymbols) TxSamples_ifdma2];
 
%============================ Noise Generation =====================
 
tmpn = randn(1,numSymbols+SP.CPsize);
complexNoise = tmpn /sqrt(2) ; %complexNoise = (tmpn(1,:) + 1i*tmpn(2,:))/sqrt(2);
noisePower =(10^(-SP.SNR(n)/10));
noise_= sqrt(noisePower)*complexNoise;%noise_= sqrt(noisePower/Q)*complexNoise
 
%=============== Channel and CFO for User 1 ==============================
RxSamples_u1 = filter(SP.channel(1,:), 1, TxSamples_u1); % Multipath Channel
 
RxSamples_u1 = RxSamples_u1.*exp((1i*2*pi*SP.ep1/(numSymbols))*(-SP.CPsize:(numSymbols-1)));
 
%=============== Channel and CFO for User 2 ==============================
 
RxSamples_u2 = filter(SP.channel(2,:), 1, TxSamples_u2); % Multipath Channel
 
RxSamples_u2 = RxSamples_u2.*exp((1i*2*pi*SP.ep2/(numSymbols))*(-SP.CPsize:(numSymbols-1)));
 
%============================= Received signal ============================
% RxSamples_ofdma1 = RxSamples_u1 +noise_;
RxSamples_ofdma1 = RxSamples_u1 + RxSamples_u2+noise_;
%% remove CP
Y_ofdma1 = RxSamples_ofdma1(SP.CPsize+1:numSymbols+SP.CPsize) ;
 
Y_ofdma2=fft(Y_ofdma1);
% %%=============compensation channel and CFO =============
HC=H*CT1;
%% MMSE Equalization
C=inv(HC'*HC+10^(-SP.SNR(n)/10)*eye(N))*HC';
Y_ofdmaC=C*Y_ofdma2.';
 
%% cancel NO-subcarrier
Y_ofdma= I1'*Y_ofdmaC;
 
demodulated_symbol1_conv=qamdemod(Y_ofdma,16);
demodata_ofdma=demodulated_symbol1_conv;
%[Num1,noe_ofdm(k)]=biterr(data1,demodata_ofdma); 
[~,ber_ofdm(k)]=biterr(data1,demodata_ofdma);
% noe_ofdm(k)=sum(abs((data1-demodata_ofdma)));
end
BER_ofdm(n) =mean(ber_ofdm);
% BER_ofdm(n,:) =sum(noe_ofdm)/(SP.numRun*N);
end
 
semilogy(SP.SNR,BER_ofdm,'k--s');
% toc
legend('OFDM')
xlabel('SNR (dB)'); ylabel('BER');
title('MMSE Equalization,QAM')
axis([0 35 1e-4 1 ])
grid

 
Last edited by a moderator:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top