Advertisement
makispaiktis

Course 5 - Filter Delay

Aug 25th, 2023
1,033
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.91 KB | None | 0 0
  1. clear all
  2. close all
  3. clc
  4.  
  5. % 1. Basics
  6. numBits = 20000;
  7. modOrder = 16;  % for 16-QAM
  8. bitsPerSymbol = log2(modOrder);
  9. txFilt = comm.RaisedCosineTransmitFilter;
  10. rxFilt = comm.RaisedCosineReceiveFilter;
  11.  
  12. srcBits = randi([0,1],numBits,1);
  13. modOut = qammod(srcBits,modOrder,"InputType","bit","UnitAveragePower",true);
  14. txFiltOut = txFilt(modOut);
  15.  
  16. SNR = 7;  % dB
  17. chanOut = awgn(txFiltOut,SNR,"measured");
  18.  
  19. rxFiltOut = rxFilt(chanOut);
  20. demodOut = qamdemod(rxFiltOut,modOrder,"OutputType","bit","UnitAveragePower",true);
  21.  
  22.  
  23. % 2. Filter Delay
  24. delayInSymbols = txFilt.FilterSpanInSymbols/2 + rxFilt.FilterSpanInSymbols/2
  25. delayInBits = delayInSymbols * bitsPerSymbol
  26.  
  27.  
  28. % 3. Aligned bits
  29. srcAligned = srcBits(1 : (end - delayInBits));
  30. demodAligned = demodOut((delayInBits + 1) : end);
  31.  
  32.  
  33. % 4. BER
  34. numBitErrors = nnz(srcAligned ~= demodAligned)
  35. numAlignedBits = length(srcAligned)
  36. BER = numBitErrors / numAlignedBits
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement