Advertisement
makispaiktis

Course 3 - Calculate BER (in an AWGN channel)

Aug 23rd, 2023
853
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.51 KB | None | 0 0
  1. % 1. Simulation parameters
  2. numBits = 20000;
  3. modOrder = 16;
  4. % Create source signal and apply 16-QAM modulation
  5. srcBits = randi([0, 1], numBits, 1);
  6. modOut = qammod(srcBits, modOrder, "InputType", "bit", "UnitAveragePower", true);
  7.  
  8. % 2. Apply AWGN
  9. SNR = 15;
  10. chanOut = awgn(modOut, SNR);
  11. scatterplot(chanOut)
  12. demodOut = qamdemod(chanOut, modOrder, "OutputType", "bit", "UnitAveragePower", true);
  13.  
  14. % 3. Calculate BER
  15. isBitError = srcBits ~= demodOut;
  16. numBitErrors = nnz(isBitError)
  17. BER = numBitErrors / numBits
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement