Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Lab1 Matlab - Digital Communication Systems Course
- % Team:
- % Abdullah Mohamed Abdullah - 1557
- % AbdelRahman Tarik ElBakri - 2447
- % Ahmed Tawfieck - 1386
- function Lab1(Num_of_Bits, SNR_Begin, SNR_Step, SNR_End)
- % BER matrix containing BER per SNR
- BER = [];
- for SNR = SNR_Begin:SNR_Step:SNR_End
- % Generate <Num_of_Bits> random bits
- Tx_Bits = randi([0 1], 1, Num_of_Bits);
- % Calculate AWGN power
- AWGN_Power = Gen_AWGN(Tx_Bits, SNR);
- % Apply AWGN to the transmitted signal
- Rx_Bits = Tx_Bits + AWGN_Power;
- % Decide whether the received bit is 1 or 0 with threshold 0.5
- Rx_Bits = Rx_Bits > 0.5;
- % Calculate BER Comparing between transmitted and received signals
- BER = [BER biterr(Tx_Bits, Rx_Bits)];
- end
- % Plot SNR against BER on a logarithmic scale Y-axis
- semilogy([SNR_Begin:SNR_Step:SNR_End], BER);
- ylabel('BER');
- xlabel('SNR (dB)');
- grid;
- end
- % Defining local function to calculate AWGN
- function NoisePower = Gen_AWGN(Tx_Bits, SNR)
- % Calculating transmitted signal power
- Ptx = mean(Tx_Bits.^2);
- % Calculate AWGN power
- NoisePower = sqrt(Ptx/(2*SNR)) * [randn(size(Tx_Bits)) + 1j * randn(size(Tx_Bits))];
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement