Advertisement
makispaiktis

Course 4 - Transmit and Receiver Filters

Aug 25th, 2023
1,203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.95 KB | None | 0 0
  1. clear all
  2. close all
  3. clc
  4.  
  5. % 1. Simulation parameters
  6. numBits = 20000;
  7. modOrder = 16;
  8. srcBits = randi([0, 1], numBits, 1);
  9. modOut = qammod(srcBits, modOrder, "InputType", "bit", "UnitAveragePower", true);
  10.  
  11. % 2. Create the filters from Communications Toolbox ('comm' variable)
  12. txFilt = comm.RaisedCosineTransmitFilter
  13. rxFilt = comm.RaisedCosineReceiveFilter
  14.  
  15. % 3. Apply the filter to the 16-QAM modulated signal
  16. txFiltOut = txFilt(modOut)
  17.  
  18. % 4. AWGN Channel - "measured" calculates the input signal's power and scales the noise power based on the SNR
  19. SNR_dB = 7;
  20. chanOut = awgn(txFiltOut, SNR_dB, "measured");
  21.  
  22. % 5. Receiver filter
  23. rxFiltOut = rxFilt(chanOut);
  24.  
  25. % 6. Back into bits
  26. scatterplot(rxFiltOut)
  27. title("Receive Filter Output")
  28. demodOut = qamdemod(rxFiltOut,modOrder,"OutputType","bit","UnitAveragePower",true);
  29.  
  30. specAn = dsp.SpectrumAnalyzer("NumInputPorts", 2, "SpectralAverages", 50, "ShowLegend", true);
  31. specAn(txFiltOut,chanOut);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement