f2t1
Newbie level 4
- Joined
- Mar 15, 2010
- Messages
- 5
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- indonesia
- Activity points
- 1,322
hi matlabers, i am trying to compute BER in ofdm but did not get the curve that i look for.anyone can help me?this is my code..
dataType = '16QAM'; % Modulation format.
totalSubcarriers = 1024; % Number of total subcarriers.
numSymbols = 16; % Data block size.
Fs = 5e6; % System bandwidth.
Ts = 1/Fs; % System sampling rate.
Nos = 4; % Oversampling factor.
Nsub = totalSubcarriers;
Fsub = [0:Nsub-1]*Fs/Nsub; % Subcarrier spacing
numRuns = 1000; % Number of runs.
M=16;
EbN0dB = [0:999];
for n = 1:numRuns,
% Generate random data.
if dataType == '16QAM'
ipBit = randint(1,numSymbols,M);
%Data Modulation
ipMod = (1/sqrt(10))*qammod(ipBit,M); % 16QAM modulation
end
% Time range of the OFDM symbol.dataType = '16QAM'; % Modulation format.
% Time range of the OFDM symbol.
t = [0:Ts/Nos:Nsub*Ts];
% OFDM modulation.
for k = 1:numSymbols,
y= ipMod(k)*exp(j*2*pi*Fsub(k)*t);
data_rx = y.*exp(-j*2*pi*Fsub(k)*t);
data_rx = data_rx,1);
end
ipBitHat = qamdemod(data_rx*sqrt(10),M); % rxData =qamdemod(rxDataMod*sqrt(10),M);
nErr = size(find(ipBit - ipBitHat),2);
end
simBer = nErr/numSymbols;
semilogy(EbN0dB,simBer,'bx-','LineWidth',2,'MarkerSize',5);
axis([0 16 10^-5 1]);
grid on
dataType = '16QAM'; % Modulation format.
totalSubcarriers = 1024; % Number of total subcarriers.
numSymbols = 16; % Data block size.
Fs = 5e6; % System bandwidth.
Ts = 1/Fs; % System sampling rate.
Nos = 4; % Oversampling factor.
Nsub = totalSubcarriers;
Fsub = [0:Nsub-1]*Fs/Nsub; % Subcarrier spacing
numRuns = 1000; % Number of runs.
M=16;
EbN0dB = [0:999];
for n = 1:numRuns,
% Generate random data.
if dataType == '16QAM'
ipBit = randint(1,numSymbols,M);
%Data Modulation
ipMod = (1/sqrt(10))*qammod(ipBit,M); % 16QAM modulation
end
% Time range of the OFDM symbol.dataType = '16QAM'; % Modulation format.
% Time range of the OFDM symbol.
t = [0:Ts/Nos:Nsub*Ts];
% OFDM modulation.
for k = 1:numSymbols,
y= ipMod(k)*exp(j*2*pi*Fsub(k)*t);
data_rx = y.*exp(-j*2*pi*Fsub(k)*t);
data_rx = data_rx,1);
end
ipBitHat = qamdemod(data_rx*sqrt(10),M); % rxData =qamdemod(rxDataMod*sqrt(10),M);
nErr = size(find(ipBit - ipBitHat),2);
end
simBer = nErr/numSymbols;
semilogy(EbN0dB,simBer,'bx-','LineWidth',2,'MarkerSize',5);
axis([0 16 10^-5 1]);
grid on