How to plot BER graph for OOk modulation..

15 views (last 30 days)
I tried following code to calculate BER for ook modulation. I dont know if its correct or not....If its wrong then whats the correct way to do it?
% Frame Length
bit_count = 1000;
SNR = 0: 1:40; %Range of SNR over which to simulate
uncoded_bits = round(rand(1,bit_count)) % Generate some random bits
for aa = 1: 1: length(SNR)
T_Errors = 0;
T_bits = 0;
while T_Errors <500 % Keep going until you get 100 errors
% ook modulator
tx =uncoded_bits; %Is this correct????
N0 = 1/10^(SNR(aa)/10); % Noise variance
% Rayleigh channel fading
h = 1/sqrt(2)*[randn(1,length(tx)) + j*randn(1,length(tx))];
% Send over Gaussian Link to the receiver
rx = h.*tx + sqrt(N0/2)*(randn(1,length(tx))+i*randn(1,length(tx)));
%--------------------------------------------------------------------------
% Equalization to remove fading effects. Ideal Equalization
% Considered
rx = rx./h;
% BPSK demodulator at the Receiver
rx2 = rx > 0
% Calculate Bit Errors
diff = rx2-uncoded_bits
T_Errors = T_Errors + sum(abs(diff))
T_bits = T_bits + length(uncoded_bits)
end
% Calculate Bit Error Rate
BER(aa) = T_Errors / T_bits;
disp(sprintf('bit error probability = %f',BER(aa)));
end

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!