Vous êtes sur la page 1sur 9

Appendix A :

M = 4; % Modulation alphabet
x = 2 ;% for data rate loop
n = 2 % for modulation loop
EbNoVec = (-10:20)'; %SINR from -10 to 20
while M< 64
M = 2^ n ;
F = 1000 ;% factor for noise from other ENode b
if M == 4
EbNoVec= ( -10 : 2.4 ) ; % QPSK MODULATION
end
if M == 16
EbNoVec = ( 2.4 : 8.4 ) ; % 16PSK MODULATION
end
if M == 64
EbNoVec = ( 8.4 : 20 ) ; %64PSK MODULATION
end
k = log2(M);
% Bits/symbol
numSC = 128;
% Number of OFDM subcarriers
cpLen = 32;
% OFDM cyclic prefix length
maxBitErrors = 100; % Maximum number of bit errors
maxNumBits = 1e7;
% Maximum number of bits transmitted
hMod = modem.qammod(M);
% Create a 4,16,64-QAM modulator
hMod.InputType = 'Bit';
% Accept bits as inputs
hMod.SymbolOrder = 'Gray';
% Accept bits as inputs
hDemod = modem.qamdemod(hMod); % Create a 16-QAM based on
the modulator

hOFDMmod =
comm.OFDMModulator('FFTLength',numSC,'CyclicPrefixLength',cpLen);
%PREAPAR TO OFDM MODULATION
hOFDMdemod =
comm.OFDMDemodulator('FFTLength',numSC,'CyclicPrefixLength',cpLe
n); % PREAPAR TO OFDM DEMODULATION
hChan = comm.AWGNChannel('NoiseMethod','Variance', ...
'VarianceSource','Input port'); % CREAT CHANEEL
hError = comm.ErrorRate('ResetInputPort',true); % ERROR IN CHANNEL
ofdmInfo = info(hOFDMmod);
numDC = ofdmInfo.DataInputSize(1);
frameSize = [k*numDC 1];
snrVec = EbNoVec + 10*log10(k) + 10*log10(numDC/numSC); %
CALCULATE SNR
snrVec2 = 10*log10(k) + 10*log10(numDC/numSC); % CALCULATE SNR
FOR A INTERFERRE ENODE B
snrVec3 = 10*log10(k) + 10*log10(numDC/numSC); % CALCULATE SNR
FOR A INTERFERRE ENODE B
snrVec4 = 10*log10(k) + 10*log10(numDC/numSC); % CALCULATE SNR
FOR A INTERFERRE ENODE B
berVec = zeros(length(EbNoVec),3); % DEFINE BIT ERROR RATE
errorStats = zeros(1,3); %DEFINE ERROR STATE
for m = 1:length(EbNoVec)
snr = snrVec(m);
whileerrorStats(2) <= maxBitErrors&&errorStats(3) <= maxNumBits
dataIn = randi([0,1],frameSize);
% Generate binary data
MODTx = modulate(hMod,dataIn);
% Apply modulation
txSig = step(hOFDMmod,MODTx);
% Apply OFDM modulation
powerDB0 = 10*log10(var(txSig));
% Calculate Tx signal
power
noiseVar0 = 10.^(0.1*(powerDB0-snr));
% %CALCULATE NOISE
noiseVar = noiseVar0
% Calculate the noise variance
rxSig = step(hChan,txSig,noiseVar);
% Pass the signal through a
noisy channel
OFDMDE = step(hOFDMdemod,rxSig);
% Apply OFDM
demodulation

dataOut = demodulate(hDemod,OFDMDE);
% Apply
demodulation
errorStats = step(hError,dataIn,dataOut,0); % Collect error statistics
end
berVec(m,:) = errorStats;
% Save BER data
errorStats = step(hError,dataIn,dataOut,1);
% Reset the error rate
calculator
end
figure (M) % SINR VS BER
semilogy(EbNoVec,berVec(:,1),'*')
holdon
legend('Simulation+interference','sim without
interference','Location','Best')
xlabel('Eb/No (dB)')
ylabel('Bit Error Rate')
gridon
holdof
n = n +2 ;% FOR MODULATION LOOP
F = F * 2 % FOR FOR INTERFERENCE

y = x * 10^6 ;%data rate


th = ( (1 - berVec ).^3/4) * y ; %througput calculation
figure %SINR VS THROUGPUT
semilogy(EbNoVec,th(:,1),'*')
holdon
legend('Simulation+interference','sim without
interference','Location','Best')
xlabel('Eb/No (dB)')
ylabel('throughput')
gridon
holdof
x = x + 2 ;% FOR DATA RATE INCERMENT

end

Appendix B :
M = 4; % Modulation alphabet
x = 2 ;% for data rate loop
n = 2 % for modulation loop
EbNoVec = (-10:20)'; %SINR from -10 to 20
while M< 64
M = 2^ n ;
F = 1000 ;%factor for noise from other ENode b
if M == 4
EbNoVec= ( -10 : 2.4 ) ; % QPSK MODULATION
end
if M == 16
EbNoVec = ( 2.4 : 8.4 ) ; % 16PSK MODULATION
end
if M == 64
EbNoVec = ( 8.4 : 20 ) ; %64PSK MODULATION
end
k = log2(M);

% Bits/symbol

numSC = 128;
cpLen = 32;

% Number of OFDM subcarriers


% OFDM cyclic prefix length

maxBitErrors = 100;

% Maximum number of bit errors

maxNumBits = 1e7;

% Maximum number of bits transmitted

hMod = modem.qammod(M);
% Create a 4,16,64-QAM modulator
hMod.InputType = 'Bit';

% Accept bits as inputs


hMod.SymbolOrder = 'Gray';
% Accept bits as inputs
hDemod = modem.qamdemod(hMod);
% Create a 16-QAM based on the modulator

hOFDMmod =
comm.OFDMModulator('FFTLength',numSC,'CyclicPrefixLength',cpLen);
%PREAPAR TO OFDM MODULATION
hOFDMdemod =
comm.OFDMDemodulator('FFTLength',numSC,'CyclicPrefixLength',cpLe
n); % PREAPAR TO OFDM DEMODULATION
hChan = comm.AWGNChannel('NoiseMethod','Variance', ...
'VarianceSource','Input port'); % CREAT CHANEEL
hError = comm.ErrorRate('ResetInputPort',true);
% ERROR IN CHANNEL
ofdmInfo = info(hOFDMmod);
numDC = ofdmInfo.DataInputSize(1);
frameSize = [k*numDC 1];
snrVec = EbNoVec + 10*log10(k) + 10*log10(numDC/numSC); %
CALCULATE SNR
snrVec2 = 10*log10(k) + 10*log10(numDC/numSC); % CALCULATE SNR
FOR A INTERFERRE ENODE B
snrVec3 = 10*log10(k) + 10*log10(numDC/numSC); % CALCULATE SNR
FOR A INTERFERRE ENODE B
snrVec4 = 10*log10(k) + 10*log10(numDC/numSC); % CALCULATE SNR
FOR A INTERFERRE ENODE B
berVec = zeros(length(EbNoVec),3); % DEFINE BIT ERROR RATE
errorStats = zeros(1,3); %DEFINE ERROR STATE
for m = 1:length(EbNoVec)

snr = snrVec(m);
snr2= snrVec2; % define interference signal snr
snr3 = snrVec3 ;
snr4 = snrVec4 ;
whileerrorStats(2) <= maxBitErrors&&errorStats(3) <= maxNumBits
dataIn = randi([0,1],frameSize);
% Generate binary data
MODTx = modulate(hMod,dataIn);
% Apply modulation
txSig = step(hOFDMmod,MODTx);
% Apply OFDM modulation
powerDB0 = 10*log10(var(txSig));
% Calculate Tx signal
power
noiseVar0 = 10.^(0.1*(powerDB0-snr));
% %CALCULATE
NOISE
dataI1 = randi([0,1],frameSize);
% Generate
interference1
MODTx1 = modulate(hMod,dataI1);
% Apply modulation
txSig1 = step(hOFDMmod,MODTx1);
% Apply OFDM
modulation
powerDB1 = 10*log10(var(txSig1))* (1/10);
noiseVar1 = 10.^(0.1*(powerDB1-snr2));
dataI2 = randi([0,1],frameSize);
% Generate
interference2
MODTx2 = modulate(hMod,dataI2);
% Apply QPSK
modulation
txSig2 = step(hOFDMmod,MODTx2);
% Apply OFDM
modulation
powerDB2 = 10*log10(var(txSig2))* (1/10);
noiseVar2 = 10.^(0.1*(powerDB2-snr3));
dataI3 = randi([0,1],frameSize);
% Generate
interference3
MODTx3 = modulate(hMod,dataI3);
% Apply QPSK
modulation
txSig3 = step(hOFDMmod,MODTx3);
% Apply OFDM
modulation
powerDB3 = 10*log10(var(txSig3))* (1/100);
noiseVar3 = 10.^(0.1*(powerDB3-snr4));
noiseVar = noiseVar0 + (noiseVar1/F) + (noiseVar2/F) + (noiseVar3/F);
% Calculate the noise variance
rxSig = step(hChan,txSig,noiseVar);
% Pass the signal through a
noisy channel

OFDMDE = step(hOFDMdemod,rxSig);
demodulation

% Apply OFDM

dataOut = demodulate(hDemod,OFDMDE);
% Apply
demodulation
errorStats = step(hError,dataIn,dataOut,0); % Collect error statistics
end
berVec(m,:) = errorStats;
% Save BER data
errorStats = step(hError,dataIn,dataOut,1);
% Reset the error rate
calculator
end
figure (M) % SINR VS BER
semilogy(EbNoVec,berVec(:,1),'*')
holdon
legend('Simulation+interference','sim without
interference','Location','Best')
xlabel('Eb/No (dB)')
ylabel('Bit Error Rate')
gridon
holdof
n = n +2 ;% FOR MODULATION LOOP
F = F * 2 % FOR FOR INTERFERENCE

y = x * 10^6 ;%data rate


th = ( (1 - berVec ).^3/4) * y ; %througput calculation
figure %SINR VS THROUGPUT
semilogy(EbNoVec,th(:,1),'*')
holdon
legend('Simulation+interference','sim without
interference','Location','Best')
xlabel('Eb/No (dB)')
ylabel('throughput')
gridon
holdof

x = x + 2 ;% FOR DATA RATE INCERMENT


end

Vous aimerez peut-être aussi